So I have a quick question about relative fonts. Suppose I have some html like this and some css like this
- Code: Select all
<ul>
<li></li>
<li></li>
<li></li>
</ul>
- Code: Select all
ul li
{
display:inline-block;
}
When you apply display inline-block to the <li>'s you will end up with white space between them, now one way to deal with the white space issue to change your css like this
- Code: Select all
ul
{
font-size:0;
}
ul li
{
display:inline-block;
font-size:16px;
}
That eliminates the white space, and then resets the font size of the <li>'s to 16px, but supposed you don’t want to used a fixed size font, because using fixed size fonts is generally consider bad practice from a usability stand point, as it prevents users resizing the text.
well the obvious thing to do is to use a relative font instead like this.
- Code: Select all
ul li
{
display:inline-block;
font-size:100%;
}
or this
- Code: Select all
ul li
{
display:inline-block;
font-size:1em;
}
The issue however is that it doesn't work, though I'm not entirely clear on why it doesn't work.
So my question is why when I do this
- Code: Select all
ul
{
font-size:0;
}
ul li
{
display:inline-block;
font-size:100%;
}
or this
- Code: Select all
ul
{
font-size:0;
}
ul li
{
display:inline-block;
font-size:1em;
}
Why does the text size of the child <li> not get reset to 16px which is the default size of text in my browser.
now I'm assuming its probably because the child <li>'s are using the parent <ul>'s font size to scale off of instead of the browsers default font size of 16px so of course 100% or 1em of 0 is of course 0.
which brings me nicely to my next question, assuming that my understanding of what is going on is correct how then would you get the child <li>'s to scale off of the browser default font size of 16px of instead of the parent <ul>'s font size of 0
can I use rem's maybe ? and if so how because again I'm not totally clear on how rem's work.