entropy Posted August 25, 2012 Share Posted August 25, 2012 Hello. I am trying to get a background fit around two floating divs: <html><head><style type="text/css">body {width: 800px;}.toptitle {background-color: #FF0000;margin: 0;padding: 1em 1em;}.logo {float: left;}.search {float: right;}</style></head><body><div class="toptitle"> <div class="logo"> <img src="image.gif" width="200px" height="65px"> </div> <div class="search"> Search: </div></div></body></html> The background shrinks to the top of the divs, while I want it to neatly fit around them. I can't give it a fixed height, because the size of the image is beforehand unknown. Link to comment Share on other sites More sharing options...
dsonesuk Posted August 25, 2012 Share Posted August 25, 2012 use overflow:hidden; for .title, the parent element cannot detect area of floated elements, but using overflow: hidden fixes this. Link to comment Share on other sites More sharing options...
entropy Posted August 25, 2012 Author Share Posted August 25, 2012 use overflow:hidden; for .title, the parent element cannot detect area of floated elements, but using overflow: hidden fixes this.Problem fixed! Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now