Jump to content

[SOLVED] Pixel and Percentage widths.


JasonLewis

Recommended Posts

I have a layout that I'm coding but I'm stuck.

 

I have two div's next to each other. The one on the left has a fixed width of 364px. They are both floating left. I want the second one to stretch the rest of the document, so it hits the scroll bars but stays next to the one on the left.

 

Here is my CSS:

div#newsletter_container {
float:left;
width:364px;
height:143px;
background-image:url('images/15.gif');
}

div#welcome_container {
float:left;
margin-left:15px;
width:100%;
height:143px;
background-image:url('images/17.gif');*/
}

 

Of course, using 100% means it is stretching the whole document, which is bad! I want this to be resizable in different screen resolutions which is why I'm using percentage for the right div. The left one NEEDS to be fixed width.

 

Here is my HTML:

<div id="newsletter_container">
Text
</div>

<div id="welcome_container">
Text 2
</div>

 

However, Text 2 appears underneath Text. Any ideas on where I should be going with this?

 

Cheers.

Link to comment
https://forums.phpfreaks.com/topic/114409-solved-pixel-and-percentage-widths/
Share on other sites

CSS"

div#newsletter_container {
        float: left;
width: 364px;
height:143px;
background-image:url('images/15.gif');
}

div#welcome_container {
margin-left: 365px;
height:143px;
background-image:url('images/17.gif');
}

 

HTML:

<div id="newsletter_container">
Text
</div>

<div id="welcome_container">
Text 2
</div>

 

Notice the first side (left side div) floats left with a fixed width.  The right side div has a left margin of the left divs width +a few pixels for borders etc.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.