Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
How to stop scaling divs from overlapping?
Old 03-28-2008, 07:14 PM How to stop scaling divs from overlapping?
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
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?


Thanks in advance,

Nathand
Nathand is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-28-2008, 09:56 PM Re: How to stop scaling divs from overlapping?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
May we see your code please?
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 03-28-2008, 10:38 PM Re: How to stop scaling divs from overlapping?
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
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

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 03-28-2008, 10:56 PM Re: How to stop scaling divs from overlapping?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
When I need an image to resize inside a scalable div, I do this:

HTML Code:
<head>
<style>
#liquid {
    width: 50%;
}

#liquid img {
    width: 100%;
}

</style>
</head>

<body>

<div id="liquid">
    <img src="wherever/whatever.png" alt="whatever" />
</div>

</body>
I link to styles instead of putting them in the head like that, but it is easier to show it all on one page like this.
__________________
Join me on
Please login or register to view this content. Registration is FREE

Last edited by wayfarer07; 03-28-2008 at 10:57 PM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 03-29-2008, 10:45 AM Re: How to stop scaling divs from overlapping?
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
Sorry about not responding sooner.

Here's the code:
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="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?


Thanks,

Nathand
Nathand is offline
Reply With Quote
View Public Profile
 
Old 03-29-2008, 11:12 AM Re: How to stop scaling divs from overlapping?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Code:
#liquid {
    max-width: 600px;
    min-width: 300px;
}
You get the idea.

This doesn't work in IE 6 and below, however.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 03-29-2008, 11:16 AM Re: How to stop scaling divs from overlapping?
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
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 !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 03-29-2008, 11:18 AM Re: How to stop scaling divs from overlapping?
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
wayfarer07 - That's exactly what I need, but since most people still use IE6 and below I can't use that.

LadynRed - Could you show me an example of what you mean? Do I apply the margin to the pic or the div?


Thanks,

Nathand
Nathand is offline
Reply With Quote
View Public Profile
 
Old 03-29-2008, 11:22 AM Re: How to stop scaling divs from overlapping?
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
Well, since you're floating the divs, it would be best to put a right margin on the photo div as that will not trigger a float margin bug in IE6.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 03-29-2008, 11:29 AM Re: How to stop scaling divs from overlapping?
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
I changed the photo's div to this:

Code:
    <div style="position: relative; width: 25%; background-color: #CECECE; text-align: center; float: left; margin-right: 5%;">
    <img src="4700ANLOmodel.JPG">
    <br>
    </div>
But the problem still occurs?


Nathan
Nathand is offline
Reply With Quote
View Public Profile
 
Old 03-29-2008, 07:16 PM Re: How to stop scaling divs from overlapping?
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
Get RID of the relative positioning.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 03-29-2008, 07:52 PM Re: How to stop scaling divs from overlapping?
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
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>
Nathand is offline
Reply With Quote
View Public Profile
 
Old 03-29-2008, 09:31 PM Re: How to stop scaling divs from overlapping?
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Nathan you can use a little Javascript to get the max-width for IE.

HTML Code:
width:expression( 
    document.body.clientWidth > (500/12) * 
    parseInt(document.body.currentStyle.fontSize) ? "30em" : "auto");
}
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

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 04-01-2008, 10:29 PM Re: How to stop scaling divs from overlapping?
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
Thanks for the replies.

I never thought about having the image's div fixed width vangogh. I think that would work well for me, I'll give it a try.


Thanks,

Nathand
Nathand is offline
Reply With Quote
View Public Profile
 
Old 04-02-2008, 04:50 AM Re: How to stop scaling divs from overlapping?
vectorialpx's Avatar
Extreme Talker

Posts: 241
Name: octavian
Location: Bucharest
Trades: 0
put a fixed width at the div and overflow:auto; [if you need scrollbars] or overflow:hidden; if you don't
__________________
you can
Please login or register to view this content. Registration is FREE

Last edited by LadynRed; 04-02-2008 at 11:31 AM..
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Old 04-02-2008, 07:24 PM Re: How to stop scaling divs from overlapping?
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Glad to help Nathan.

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

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Reply     « Reply to How to stop scaling divs from overlapping?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.55428 seconds with 12 queries