Solved

Help with Div Layout

Posted on 2011-03-15
4
312 Views
Last Modified: 2012-05-11
I'm having trouble with a simple Div layout. Below is my current code. I've also attached an image (sample_layout.jpg) I'm trying to achieve. My current code doesn't work right.


<div id="wrapper" style="width:900px;border:1px solid black;">
	<div id="header" style="float:left;background:#cccccc;width:600px;height:100px"><h1>Title</h1></div>
	<div id="utils" style="float:right;text-align:right;background:#eeeeee;width:200px;height:100px">Help</div>
	<div id="content" style="background:#666666">
		Main Content Content
	</div>
</div>

Open in new window

sample-layout.jpg
0
Comment
Question by:greddin
  • 2
4 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35142677
try :

   <div id="wrapper" style="width:900px;border:1px solid black;"> 
   <div id="headerwrapper" style="width:100%;height:100px">
        <div id="header" 
            style="float:left;background:#cccccc;width:700px; height:100px"><h1>Title</h1></div> 
        <div id="utils" style="float:right;text-align:right;background:#eeeeee;width:200px;height:100px"><h1>Help</h1></div> 
   </div>
   <div id="content" style="background:#666666;height:500px"> 
                <h1>Main Content</h1>
   </div> 
</div> 

Open in new window

0
 
LVL 5

Accepted Solution

by:
meb_santoso earned 250 total points
ID: 35142697
If you are trying to achieve this:

 screen caps
Try this code: (change the colors and the border, it's only for cosmetics )

<div id="wrapper" style="width:900px;border:5px solid #FF0;">
	<div id="header" style="float:left;background:#00F;width:600px;height:100px">
    	<h1>Title</h1>
    </div>
	<div id="utils" style="float:right;text-align:right;background:#0F0;width:200px;height:100px">
    	Help
    </div>
    <div style="clear:both;"></div>
	<div id="content" style="background:#F00">
		Main Content Content
	</div>
</div>

Open in new window


What's forgotten from time to time is the following:
<div style="clear:both;"></div>

Open in new window

0
 
LVL 29

Assisted Solution

by:Paul Jackson
Paul Jackson earned 250 total points
ID: 35142714
Update without the header wrapper div which wasn't really needed:
   <div id="wrapper" style="width:900px;border:1px solid black;"> 
        <div id="header" 
            style="float:left;background:#cccccc;width:700px; height:100px"><h1>Title</h1></div> 
        <div id="utils" style="float:right;text-align:right;background:#eeeeee;width:200px;height:100px"><h1>Help</h1></div> 
   <div id="content" style="background:#666666;height:500px"> 
                <h1>Main Content</h1>
   </div> 
</div>

Open in new window

0
 

Author Closing Comment

by:greddin
ID: 35143798
Thanks guys for the the layouts. Both are actually just what I needed. I couldn't decide which to choose so I split the points.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Unordered lists (HTML ul tags) are very handy to create menus of all types, shapes and sizes.  All it takes is a little knowledge of CSS and the possibilities are endless. First off, you should know the general format for menus created using the …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now