Solved

Help with Div Layout

Posted on 2011-03-15
4
313 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
align Linkedin sign to the right page 5 35
Host asp.net pages 5 35
Could you point how to give Bootstrap's open/ close menu effect ? 25 52
flex div overflows its container 4 21
Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
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…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

773 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