SitePoint Sponsor

User Tag List

Results 1 to 21 of 21
  1. #1
    SitePoint Guru
    Join Date
    Feb 2006
    Posts
    980
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Increasing size of text problem

    If someone increases their font size on this site with FF, it moves the footer text down one line and disappears with no background. Is there a fix for this?

    Thanks much,

  2. #2
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,726
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Well you have a fixed height on the #footer, and when the text increase happens, the height of the footer should get higher, hwoever it can't because you have a fixed height set.

    If you switch it to min-height (or even remove the height declaration altogether), it shoudl work .
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  3. #3
    SitePoint Guru
    Join Date
    Feb 2006
    Posts
    980
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Neither of those work. I tried min-height: 29px and tried removing the height. Can you explain what you mean?

  4. #4
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,283
    Mentioned
    51 Post(s)
    Tagged
    2 Thread(s)
    Your Firefox must be set to enlarge text only rather than zoom. Very nice.

    Normally, setting a fixed height on something means it won't grow when the content inside does. Ryan is correct that you should *generally* avoid it.

    But the reason it's *still* not growing is because the text inside is floated. The footer doesn't "see" those floats and so doesn't enclose them (which static block containers normally do to everything inside them). You've heard of clearing divs? this kind of thing is why some people use them.

    In Internet Explorer 6 and 7, now that you have min-height instead of height, things should be growing okay with the text because the width: 100% is triggering Haslayout.

    For everyone else, you can use one of the common float-enclosing tricks:

    You could set #footer to overflow: hidden. So long as the height is min-height, it will still grow with content. Blocks with overflow set to anything other than "visible" (the default) are required to "see" their children so they can determine if there even IS any overflow. This is the solution I use most of the time. Don't use it if content must ever be able to come out of the container.

    You could set the #footer to display: inline-block. Since you've stated its width to 100% already, this should look okay, but test it. I found this started breaking my layouts when I did severe text-enlarge on smaller-width screens, but might be okay with you (or you don't deal with smaller screens maybe).

    You could set the #footer to display: table. I'm uneasy with this one since tables have their own set of rules they play by and I'm not always expecting what they do.

    You could use a fake CSS element to "clear" the floats. Once there's a "child" after the floats who clears them, the footer finally can see its last child and encloses everyone.
    After the #footer declaration:
    #footer:after {
    content: " "; (if Firefox doesn't like this, use unicode space \0a inside the quotes, but I've used an empty string before just fine)
    display: block; (only blocks clear cross-browser)
    clear: both; (you have floats in both directions)
    height: 0; (something I add for browsers who use things like font-size/line-height to make a gap)
    }

    You could float the footer itself. Floats must contain floats. Since you've set it to 100% width, it shouldn't be able to ride up alongside your main content. I don't like this solution.

    Those are the most common of the ones that don't suck.

  5. #5
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,726
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Oh, whoops. I didn't realize you had flaoted contents in the footer. I kind of guessed because my college computers don't have firebug, which I normally use to debug. So I guessed .

    You have floated <p>'s inside of the footer which (besides the min-height/height you set) makes it not even realize it has content inside of it. The footer thinks it's empty thus it won't auto expand.

    A solution you can try is overflow:hidden; on the footer. That's the simplest fix and best .

    Edit-Stommeeeeeeeeeeeeeeeeeee...
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  6. #6
    SitePoint Guru
    Join Date
    Feb 2006
    Posts
    980
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks sooo much for the explanation Stomme. I tried overflow: hidden and it works. What do you think? Would you change anything else in case someone increases font?

  7. #7
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,726
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Well anytime you set height on something that has content (text) that can be increased in size, you are just asking for trouble. You could cheat and just set the height in "em"'s that way, on resize, it wouldn't break . Everything (of what I see in your stylesheet) seems to be just in pixels.

    Another way would be to set a min-height instead of height. However, know that IE7 doesn't support it .
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  8. #8
    SitePoint Guru
    Join Date
    Feb 2006
    Posts
    980
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I changed it to ems but not sure how that helped. Check with FF. I did already change it to min-height. Check current CSS:

    Code:
    #footer{
    	width:100%;
    	min-height:1.813em;
    	overflow: hidden;
    	margin:30px 0 0 0;
    	background-color:#5a92b9;
    	padding:5px 0px;
    	font-size:.65em;
    }
    
    .alignleft {
    	float: left;
    	margin:4px 0 0 15px;
    }
    .alignright {
    	float: right;
    	margin:4px 20px 0 0px;
    }

  9. #9
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,726
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    If you set an EM height, it will just expand with text resize. PX won't. That's all .

    Do you even need to set a height on the footer? If you got rid of it, that would be best, of course .
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  10. #10
    SitePoint Guru
    Join Date
    Feb 2006
    Posts
    980
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right. Okay, removed it. So I guess it's good to go now.

  11. #11
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,726
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Yes you are. To sum up, as a golden rule, avoid setting heights on parents that have content inside of them.

    Different browsers render text bigger/smaller so you have more headaches than not if you set heights.

    Glad we could be of help .

    Edit-I shoudl mention that the overflow:hidden cut off the text. Normally it'd just hand out which isn't a HUGE deal, I guess, but you shouldn't let that happen whiel you know of the issue.
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  12. #12
    SitePoint Guru
    Join Date
    Feb 2006
    Posts
    980
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I totally am not getting what you are saying here:

    Quote Originally Posted by RyanReese View Post

    Edit-I shoudl mention that the overflow:hidden cut off the text. Normally it'd just hand out which isn't a HUGE deal, I guess, but you shouldn't let that happen whiel you know of the issue.

  13. #13
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,726
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    You had a height set. You had overflow hidden set. Which means that anything that overflows the boundaries of that height (aka the text wast oo big and was going into another line, which caused the "pseudo height" of it to be too big) will get cut off. Overflow:hidden; cuts of anything which doesn't conform to the dimensions set (if there are any)

    For example

    <div>text<br>text</div>

    If you set the height to that to 10px, and overflow:hidden; without a doubt, that 2nd text will be cut off. It's too small. Do you understand? You can normally look for overflow:hidden to be the culprit in stuff being cut off .
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  14. #14
    SitePoint Guru
    Join Date
    Feb 2006
    Posts
    980
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I do.

    And this is what I have for code now. If I remove overflow:hidden, it doesn't work:

    #footer{
    width:100%;
    overflow: hidden;
    margin:30px 0 0 0;
    background-color:#5a92b9;
    padding:5px 0px;
    font-size:.65em;
    }

    .alignleft {
    float: left;
    margin:4px 0 0 15px;
    }
    .alignright {
    float: right;
    margin:4px 20px 0 0px;
    }

  15. #15
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,726
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Well you don't haev a height set which means you won't get anything cut off, so taht example is flawed right there .

    You have floated children, alignleft and alignright. Without overflow:hidden; on the parent, it won't contain the floats. Which means the parent thinks it'd be empty without it, and the height is essentially 0.

    Now, you *could* do other stuff instead of overflow:hidden; (ONLY IF you need something to hang out for visual purposes), such as the clearfix (google if you don't know what that is)

    With the height being 0 (without overflow:hidden) some stuff, aka the background color, won't show up .

    Should have kept my mouth shut about the overflow:hidden comment .
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  16. #16
    SitePoint Guru
    Join Date
    Feb 2006
    Posts
    980
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe so. I think it may be hard too b/c you said you don't have Firebug. I don't get what you're saying. Yes, if I remove overflow:hidden the blue bg goes away and you can't see white text. Please show me what you're talking about with code for this footer.

  17. #17
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,726
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    I don't need firebug to explain what I am talking about, well, I shouldn't .

    Anyway take this example.
    Code:
    #footer{
    width:100%;
    /*overflow: hidden;*/
    margin:30px 0 0 0;
    background-color:#5a92b9;
    padding:5px 0px;
    font-size:.65em;
    }
    Now, since you have floated children, the #footer is calculated to be basically 0 height. There is no other content in the footer that isn't floated, so it will be 0 height. Now, when you have a 0 height element, it won't show background colors or images. Basic stuff.

    Take this example
    Code:
    #footer{
    width:100%;
    height:20px;
    overflow: hidden;
    margin:30px 0 0 0;
    background-color:#5a92b9;
    padding:5px 0px;
    font-size:.65em;
    }
    You have a height set. This is basically your last example you had in the beginning of this thread. When the user will text resize, the content will eventually outgrow the 20px, and due to the overflow:hidden; set, it will chop off anything exceeding 20px, which means basically, anything on 2nd line will be cut off. If you remove the overflow:hidden in this example, yes the text won't be choppedoff, however it still thinks THERE ARE NO CHILDREN. Which means there is no background color. Even though tehre is clearly content in there, the parent #footer doesn't think so. It needs that overflow:hidden; to c ontain the floats (or another clearing way, such as the clearfix)

    I haev another 5 minutes before I need to go to work, so if you have any more questions I'll have to wait to respond until I getoff work. Hopefully this was clear enough for you.
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  18. #18
    SitePoint Guru
    Join Date
    Feb 2006
    Posts
    980
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, very. Thanks. I thought you were saying to remove the overflow:hidden from the latest code I have. Okay, you're not. Got it. I get it :-). Code is good. I'll try the clear float option for kicks too.

  19. #19
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,726
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Glad I could help . You're welcome.
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  20. #20
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,283
    Mentioned
    51 Post(s)
    Tagged
    2 Thread(s)
    I want to clarify something I said earlier:
    Quote Originally Posted by me
    You could set #footer to overflow: hidden. So long as the height is min-height, it will still grow with content.
    The second sentence... does not mean you need min-height to use overflow:hidden, but that min-height is better than height (for reasons Ryan mentioned above, cutoff). No height at all (which means height: auto by default) is also good :)

  21. #21
    SitePoint Guru
    Join Date
    Feb 2006
    Posts
    980
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got it. Thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •