Solved

How can I markup my html to achieve the desired result in my diagram?

Posted on 2013-11-23
3
217 Views
Last Modified: 2013-11-25
Is there a clean way to achieve the result in the diagram with html and css? My goal is to have the header and page be centered, with some side panel off to the side. The key part is that the side panel should be vertically top aligned with the page div. I want a solution which will automatically work irrespective of the height of the header, i.e I'm not fixing the side panel top position to accommodate the header height. I am pulling in bootstrap (for other reasons) so feel free if necessary to reference (or not) anything from there. Please note that the header and page do have set widths, i.e should use or be embedded within a div with class "sitewidth".

Suggested starting points could be:

<div class="centered sitewidth">
	<div id="header"></div>
	<div id="page"></div>
</div>

Open in new window


OR

	<div id="header" class="centered sitewidth"></div>
	<div id="page" class="centered sitewidth"></div>

Open in new window


Where can I put the side panel div to get the desired result?
Untitled.png
0
Comment
Question by:paddycobbett
3 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39671935
You can do something like this
http://jsfiddle.net/GaryC123/ag43D/2/

<div id="container">
<div id="header">Header</div>
<div id="innercontainer">
<div id="side">Side</div>
<div id="page">Page</div>
</div>
</div>

Open in new window

#header {
    width:100px;
    margin:0 auto
}
#container {
    width:200px;
    margin:auto ;
}
#innercontainer {
    margin-left:-50px;
}
#page {
    width:100px;
    margin:0 auto;
    float:left;
}
#side {
    width:100px;
float:left
}

Open in new window

0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39671974
I like using pre made grid's for this.  Because mobile has become so important, I like responsive grid's from http://getbootstrap.com/ or http://foundation.zurb.com/

In bootstrap http://jsbin.com/uCusEVI/1/ you can see for larger screens you see your sample, but in smaller screens, the div's stack.  It gets more complex to build the page, but makes it easier for mobile, tab and desktop users with one  page.

<div class="row">
  <div class="col-md-8 col-md-offset-2">Header</div>
</div>
<div class="row">
     <div class="col-md-2">Left</div>
     <div class="col-md-10">Middle</div>
<div>

Open in new window

0
 
LVL 1

Author Closing Comment

by:paddycobbett
ID: 39676402
Thanks, I think this solution was preferable for my particular case.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
jquery, html5 UI 1 49
CSS Divs in Safari 3 19
CSS grid style change 2 14
bootstrap table auto width input box 1 23
When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

760 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

22 Experts available now in Live!

Get 1:1 Help Now