Containing Divs within a Parent Div

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

smooth

Garrett
Thread Starter
Joined
Sep 26, 2005
Messages
4,029
Hi everybody :)

I have a simple example html page to test this with:

HTML:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>

<div style="width: 100%; float: left;border:1px solid #000000;">
	<div style="float: left; width: 185px;border:1px solid red;">left</div>
	<div style="float: left; width: 790px;border:1px solid blue;margin:auto;">center</div>
	<div style="float: left; width: 185px;border:1px solid green;">right</div>
</div> 

</body>
</html>
Now, if you run this page, you'll see that everything is lined up pretty well, but when make the browser thinner, the center div ends up going outside of it's container div.

I was wondering is there a way to keep fixed width divs within their container?

Any help is greatly appreciated :)
 

tomdkat

Retired Trusted Advisor
Joined
May 6, 2006
Messages
7,148
I was wondering is there a way to keep fixed width divs within their container?
There sure is. Make sure the fixed width DIV is contained within a DIV that is guaranteed to be as wide as the fixed width DIV. :)

You could use the min-width CSS attribute to control the width of the parent DIV (so it won't be more narrow than the fixed width child DIV) but IE doesn't support min-width (at least pre-IE8 versions don't and I don't know about IE8). *Sigh*

Peace...
 

colinsp

Colin
Joined
Sep 5, 2007
Messages
2,322
I know pre IE8 browsers that don't support min-height actually treat height as a minimum so maybe they do the same for width? Worth a try with some IE specific CSS?
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top