CSS line-height problem in Firefox 5 - firefox

I'm running into a vertical positioning problem with a couple of elements on a page in Firefox 5. When I set a line-height on a piece of text, and give it an equal height, it doesn't center vertically the way it should. Instead it sticks to the top of its line-height.
The page in question is here: http://www.tyndale.ca/~missiodei/
Here are the two problem elements along with their CSS. In both cases the text is pushed up in FF5 but displays properly (vertically centered within its line-height) in Chrome/Chromium.
the large title link in the banner (#blogtitle a)
position:relative;
display:block;
margin:0;
padding:0;
color:#fff;
text-decoration:none;
letter-spacing:.1em;
font-family:"Palatino Linotype", Palatino, serif;
font-weight:bold;
opacity:0.6;
height:120px;
line-height:120px;
any of the drop-caps that float at the beginning of new sections of body text (p.openingPar:first-letter)
font-size:3em;
font-weight:bold;
position:relative;
float:left;
height:48px;
color:#ccc;
line-height:48px;
margin-right:4px;
You might not see these drop caps unless you look at the page using Chrome or Safari, since most of them aren't showing up at all in FF. (I'm not sure why these styles aren't being respected either).
Finally, it would be helpful to know whether this is a problem unique to FF5 or whether 3.6 and 4.0 have the same problem. I don't have any old versions of FF available for quick testing.
Thanks ahead of time for help. I've imprinted my keyboard on my forehead bashing my head over this one!

The vertical centering seems to work fine for me....
The lack of first letter styling is https://bugzilla.mozilla.org/show_bug.cgi?id=8253

Try using <span class"dropcaps">W</span> instead of styling your opening first letter in the paragraph by selector :first-letter. Let us know if it works.

Related

Why is my font-face adding space at the baseline?

My font is doing something weird. There seems to be space being added below the font (Not the margin) that is pushing it up above the line-height. If I adjust the height it seems to be anchored to the bottom of the line height so instead of increasing the space below it actually pushes the top of the font above the line height. Is there any way, save adding margin or padding to the top, to make sure it's anchoring to the top of the line-height or middle?
CSS:
#font-face {font-family: 'AvenirLTStd-Book';src: url('/us/_media/font/2CA9EF_0_0.eot');src: url('/us/_media/font/2CA9EF_0_0.eot?#iefix') format('embedded-opentype'),url('/us/_media/font/2CA9EF_0_0.woff2') format('woff2'),url('/us/_media/font/2CA9EF_0_0.woff') format('woff'),url('/us/_media/font/2CA9EF_0_0.ttf') format('truetype');}
#font-face {font-family: 'AvenirLTStd-Black';src: url('/us/_media/font/2CA9EF_1_0.eot');src: url('/us/_media/font/2CA9EF_1_0.eot?#iefix') format('embedded-opentype'),url('/us/_media/font/2CA9EF_1_0.woff2') format('woff2'),url('/us/_media/font/2CA9EF_1_0.woff') format('woff'),url('/us/_media/font/2CA9EF_1_0.ttf') format('truetype');}
h1,h2,h3,h4,h5,h6 {
font-family:'AvenirLTStd-Black', Arial, sans-serif;
margin-top: 0;
font-weight: normal;
line-height: 1em;
color: inherit;
text-rendering: optimizelegibility;
-webkit-font-smoothing: antialiased;
letter-spacing:1px;
}
I know this is old, but I thought I'd leave a comment for others Googling this issue.
It looks like you are using Avenir from MyFonts.com, which allows you to 'tweak' your webfont package.
I had the same issue as above, changing the Line Height Adjustments to use Bounding Box (Match the bounding box of the glyphs, line gap will always be 0) fixed the issue
I used the settings in the screenshot below:
[link to screenshot is down]
The idea is to increase line-height to decrease the space at the baseline, i.e.:
h1 {
font-size: 2rem;
line-height: 3rem;
}
I was on this for a while now and since I have no Myfonts.com account and the font is free font generated by FontsQuirrel or downloaded from GF I had to experiment. In PS my font looks correct by comparison,
Montserrat vs Open Sans
But webfont is completely off.
I was than forced to test several font editing software. First I tested FontForge and could simply not figure out the proper metrics, than i got trial FontCreator that has this great feature that auto calculates the metrics which when entered in FontForge fix the issue.
But paying $79.00 min to just fix this and never use the software again did not seem feasible and I also did not want to go back and forth between the two to get the metrics. I continued to play with FontForge and finally found the solution. You must reset all values to 0 in Element -> Font Info -> OS/2 -> Metrics and than uncheck the "Is Offset"
Instead another image here is short video that shows how to fix this
http://take.ms/rJpqh
Note that for some fonts it is better to uncheck the Really use Typo metrics which helped in my case.
The attribute you have missed out is 'vertical-align' and it is probably causing all of the trouble
This tells the browser where to align the text
It has the following values (not all are listed):
baseline
sub
super
middle
top
bottom
To find out more click here

Invisible padding in input submit

I have two boxes. The first one contains simple text. The second one contains a submit input with no borders, paddings, margins.
So, why the input takes more height than the simple text?
I know that I can play with the padding and remove the box height, but for my purposes I need to set it a static height, and prepare this box to be reusable for both inputs and simple texts.
I have tried to play with line-height and vertical-align properties, without success.
What is causing that extra line-height?
There's an example to play with it.
Edit: I recently see, that the issue is only with Firefox...
I think it could be for the line-height property in the Firefox CSS:
But... in first place I can't believe what my eyes are seeing. An !important in the internal browser stylesheet? That's normal? Could this be a possible answer?
Similar question with the same answer.
But the trick Leniel suggest doesn't work for me...
The extra padding is on your .buttonarrownext class.
Fixed CSS Class:
.buttonarrownext {
cursor:pointer;
position:relative;
border-radius:4px;
text-align:center;
background:white;
border:1px solid red;
padding: 0px; /* changed the padding here */
margin:0px auto;
display:inline-block;
}
A JSFiddle to demonstrate.
As mentioned in my comment, it displays fine in IE and Chrome, but not FF. A quick solution is to replace the input with a button.
updated html would be:
<div class="container">
<div class="buttonarrownext">Siguiente</div>
<div class="buttonarrownext"><button class="reset">Siguiente</button></div>
</div>
There's no real difference as you can still fire a submit event with a click handler for the button...
It will be interesting to find out why FireFox does this though...
Updated fiddle - http://jsfiddle.net/QfPGW/2/

href not working in Firefox and opera

I am using Css3 effects to make my menu look fancier , no issues with that however , I dont know for some strange reasons , when I click on the menu items , they dont redirect to desired pages ie my href="abc.aspx" wont work in Firefox , Opera , but works well in Chrome.Here is the Css3 code which I use
#Menu a:active,
#Menu a.active:before,#Menu a:hover:before
{
Content: ' ';
position:absolute;
z-index:-1;
width:0px;
height:0px;
left:50%;
top:50%;
border-radius:50%;
box-shadow:0 0 35px 30px #ADD7E7;
}
My menu looks something
However when I remove that Css3 styling , the href works.Can anybody help me out with this as to why this happens.
Any suggestions are welcome.
Thanks
The problem may stem from styling #Menu a:active together with the pseudo elements. Try separating them or even just remove #Menu a:active from the definition altogether. Then you can set your z-index back to -1 as it will only be being applied to the pseudo element.
I've set up a jsfiddle here.
It is most likely because of this line in your css:
z-index:-1;
The default layer is 0 of the document but since on hover you are setting it to -1, you won't be able to click on it.
The z-index:-1 places the element behind the body. As such, it can't be clicked because the body is obscuring it.
This is however a little ambiguous if you haven't defined a background colour for the body, as transparent background colours may not catch clicks.
Avoid negative z-indices. They can go pretty much as high as you want in the positive numbers, more reliably then negative.

CSS max-height and overflow auto always displays vertical scroll

I have a div class set up with the following CSS style:
div.multiple_choice{
border: 1px solid black;
max-width: 300px;
max-height: 200px;
overflow: auto;
}
The problem is, when the text inside doesn't force the DIV to reach the maximum height of 200px, the vertical scroll bar still shows up. I can click on the up and down arrows but it only moves the contents up and down by about a pixel or two.
This is occuring in Google Chrome (version 18.0) and Iceweasel 11.
As it turns out, another CSS style was causing the issue:
body{
line-height: 1;
}
Anyone interested in learning about how and why this would cause an issue, can read about the line-height property here
I was having an issue with this, and I found that having position: relative on the child elements was causing the problem. Obviously this can't be the solution for everyone, especially if position: absolute is being used, but for me it worked.
Just to put in evidence the #Kuba Orlik's solution (he posted as comment on the accepted answer) that's the only one that worked for me.
Add this on inside elements:
line-height: normal;
Note: Explicitly normal not 1 because it's different
I have encounter this problem.But I solved this use the following css style:
div.yourcontainer{overflow-y:auto;}
If the container was higher than max-height,the vertical scrollbar will show.
I had this problem when trying to wrap a list (flex column) of react components in a div, I resolved it by changing margin of elements within each list item to be 0.
The approach to troubleshoot this for me was to inspect the list items (perhaps each <li> in OP) and see what styles were making the div think each list item was larger than what was visible to the human eye.
Here is an example of inspecting a rogue margin on an icon within a list item in my project:
Solution is to set the style of that icon to have a vertical margin of 0, though in my application I just made all the margin 0 and added some padding-right.
I also had this problem using Bootstrap and nav. It occurred because bootstrap definds the li in nav-tabs as: .nav-tabs > li { margin-bottom:-1px; }. To counteract this, you must also do:
.nav-tabs > li:last-child {
margin-bottom:0;
}
Without setting the last-child, the following example would always show scroll, no matter how much content is in the list:
<ul class="navs nav-tabs nav-stacked" style="max-height:80px;overflow:auto;">
<li></li>
...
</ul>
I came across this bug earlier today. In my case a list of child elements had display: inline-block instead of display: block. Switching to display: block for my list of child elements in the truncated div fixed the issue for me.
In my case, the problem was with the font. We use font-family: Galano Grotesque. Apparently, this font is rendered higher than the computed height.
<div>
<p>some text</p>
</div>
So even without max-height, when the inner p and the outer div were both computed as 20px height, there was still a scroll bar (with overflow: auto) because the font was about 1px higher than expected.
So the solution can be any one of:
Use a different font.
Add padding to the outer div. This way it will be large enough to cover the extra pixel that comes from the font. In my case, adding one pixel of padding to the bottom and one to the top solved the problem.
Set line-height to a bit larger value (in my case, from 1.25 to 1.4), so it won't interfere with the font.
Set line-height to normal because then the actual value will be influenced by the font. However, according to Mozilla, this is not the preferred way.
The reason for the vertical scroll is obvious: the scrolled content is higher than scrolling area. But when you observe their heights, they are equal!
The causes are multiple but all come down to a common one: an element inside the scrolled content overflows it and makes the result taller.
How to fix this?
find the guilty element by looking near the bottom edge of the scrolled element (or to the right if you're scrolling horizontally), because they are the most likely to overflow. You should observe a height larger that their parent's.
see what makes them overflow, be larger than their container. As other answers suggest, it can be line-height, some margin, etc. Change those properties to make them fit, or as an alternative, set overflow-y: hidden to their immediate parent.

webkit vs firefox height of text

I have quite large text (font size 28) I'm trying to align vertically in a fixed-height container.
I'm doing this by eye and just setting a margin-top so that it gets to the right spot. However, when in Firefox, I need a margin-top of 20px, in Safari I need like 15px (else it's too far down). I saw that the discrepancy was because in Safari the text element is taller than in Firefox and includes a slight amount of whitespace on top that doesn't show up in Firefox (in Firefox, the top of the text element is exactly when the text starts).
I've tried all kinda of display combinations with line-heights and perhaps adding a width/height for the text and whatnot. Nothing works.
What can I do to make this consistent? I'd hate to use JS but it seems like the only option...
For cross-browser CSS normalization I'd recommend a reset - YUI3 has a good one, Twitter Bootstrap is another good one. It basically sets paddings and margins to 0 so all browsers will behave and only adhere to YOUR css rules and not their own default rules.
For vertically aligning text to containers, if it's a single line of text, use the line-height property, and set it to equal the height of the container.
For example:
CSS:
div {
height:300px;
width: 400px;
line-height: 300px;
font-size:28px;
background-color:#F0F0F0;
}
HTML:
<div>
Some vertically centered text
</div>
Example: http://jsfiddle.net/Djvv7/
You need to apply a css reset. Good practice to use one on all projects. The most famous I know of is: http://meyerweb.com/eric/tools/css/reset/

Resources