I some nested divs that are set to 30% and 70% of the outer divs (body) width. The problem is I have a picture in the left nested div (the 30% one) that is about 25% of the body's width, so when I resize the browser window the right nested div (the 70% one) overlaps the picture.
Here are pictures of what I'm talking about:
As you can see the overlapping look really, really bad. Is there any way I can stop this from happening?
Nathan code would definitely help, but looking at your screen shots I would say your images is larger than the 30% of the browser width you're allowing. The image isn't going to resize so it forces the div to be wider than 30%.
At what width do the two divs begin to overlap?
__________________ l Search Engine Friendly Web Design | Please login or register to view this content. Registration is FREE
l Tips On Marketing, SEO, Design, and Development | Please login or register to view this content. Registration is FREE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>ScrubPros.com - <!---DESC---></title></head>
<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<div style="position: relative; width: 100%; background-color: #EFEFEF; text-align: left; float:left;">
<div style="position: relative; width:30%; background-color: #CECECE; text-align: center; float: left;">
<img src="4700ANLOmodel.JPG">
<br>
</div>
<div style="position: relative; width: 70%; background-color: #AEAEAE; text-align: left; float: left;">
<div style="position: relative; background-color: #FFAAAA; text-align: left; float: left;">
whupteedooo
</div>
<div style="position: relative; background-color: #AAFFAA; text-align: left; float: left;">
text text text text text text text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text text text text text text text
text text text text text text <br>
</div>
</div>
</div>
</body>
</html>
vangogh - You're exactly right on what's happening.
I tried making the image scale itself, but the problem is someone with a really high resolution (like a laptop) will see a very pixelated image.
Is there any way to tell the divs to stop resizing when their content can't fit in them or something?
In addition, you don't need all that relative positioning. If you don't want the div's overlapping the photo, you're going to have to apply a margin to keep them away from the photo at all times.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
Is there something else I'm doing wrong? I have this code now and it still doesn't work :-(
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>ScrubPros.com - <!---DESC---></title></head>
<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<div style="width: 100%; background-color: #EFEFEF; text-align: left; float:left;">
<div style="width: 25%; background-color: #CECECE; text-align: center; float: left; margin-right: 5%;">
<img src="4700ANLOmodel.JPG">
<br>
</div>
<div style="width: 70%; background-color: #AEAEAE; text-align: left; float: left;">
<div style="background-color: #FFAAAA; text-align: left; float: left;">
whupteedooo
</div>
<div style="background-color: #AAFFAA; text-align: left; float: left;">
text text text text text text text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text text text text text text text
text text text text text text <br>
</div>
</div>
</div>
</body>
</html>
You'll have to play with the numbers a little to get the width you want. The code above comes from this page if you want to read more about it.
I'm using the same javascript on my site at the moment.
Another option to consider is having the left column be a fixed width and then letting the right column fill the space. I'm just guessing, but I would think the left column doesn't change widths as much given it contains images.
__________________ l Search Engine Friendly Web Design | Please login or register to view this content. Registration is FREE
l Tips On Marketing, SEO, Design, and Development | Please login or register to view this content. Registration is FREE
Usually if I'm trying to develop a fluid site I'll still make several columns fixed width and then let one or two key elements expand and contract with the browser window. Much easier to control your overall layout that way.
__________________ l Search Engine Friendly Web Design | Please login or register to view this content. Registration is FREE
l Tips On Marketing, SEO, Design, and Development | Please login or register to view this content. Registration is FREE