Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hello i am trying to achieve this layout.Check link for layout details.
http://s23.postimg.org/a919dmufv/layout.png[^]

So far i have written this

XML
<body>
    <div id="content">
    <div id="header">
    </div>
    <div id="nav">
    </div>
    <div id="footer">
    </div>
    </div>
</body>


and css:

CSS
body
{
}
#content
{
    margin:0 auto;
    height:1200px;
    width:1000px;
    border:2px solid black;

}
#header
{
    margin:0 auto;
    width:inherit;
    height:200px;
    border-bottom:2px black solid;
}
#nav
{
    margin:0 auto;
    width:inherit;
    height:50px;
    border-bottom:2px solid black;
}
#footer
{

    width:inherit;
    border-top:2px solid black;
    margin-top:-1200px;
    height:200px;
    clear:both;
}


but the footer is not behaving as in diagram.Can you tell me what is wrong with my code? please dont give me some other codes because I am new to css.
Posted
Updated 25-Sep-13 7:28am
v2
Comments
Homero Rivera 25-Sep-13 14:22pm    
I might not be able to provide an answer, but I've learn a lot from this question! +5
Abhinav Gauniyal 25-Sep-13 15:05pm    
I couldnt understand :(
Karn Singh 25-Sep-13 16:14pm    
glad i asked this question
Abhinav Gauniyal 25-Sep-13 14:49pm    
Can you post another diagram of what you are getting [the wrong one]. I will surely be able to provide a answer :)
Sergey Alexandrovich Kryukov 25-Sep-13 15:05pm    
Good idea. Please provide the sample complete with HTML notify me when you are done, by commenting this comment. I'll gladly up-vote it.
—SA

1 solution

Well to achieve the exact layout you should do the following:

CSS:

CSS
#header
{   margin:0px auto;
    height:200px;
    width:1000px;
    border:2px black solid;
}
#nav
{
    margin:0 auto;
    width:1000px;
    height:50px;
    border:2px solid black;
}
#content
{
    margin:0 auto;
    height:800px;
    width:1000px;
    border:2px solid black;

}
#footer
{
    margin:0 auto;
    height:200px;
    width:1000px;
    border:2px solid black;

}



Html:

XML
<body>
    <div id="header"></div>
    <div id="nav"></div>
    <div id="content"></div>
    <div id="footer"></div>
</body>





Some things to go with:
1. Close every tag you open in html
2. Keep the layout simple ie. you wanted content after header and nav but you were placing them before.
3. I didnt do anything except rearranging them and resetting the CSS width property from Inherited to 1000px
4. You can change your width and height accordingly :)

Feel free to ask any questions :)
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 25-Sep-13 15:12pm    
Nice work, 5ed.
I must note that such layout style is not really good, because the width of screen is not used, and narrower browser window won't show the full page. However, this flawed design is often used (some 99.99% Web sites are ugly anyway) and this is what OP required, not your fault.
—SA
Karn Singh 25-Sep-13 16:06pm    
i know this is one ugly layout but i am still a learner..i am trying out all possible layouts i can think of..no offence
Abhinav Gauniyal 25-Sep-13 16:11pm    
Well you are on the right track , nobody creates perfect things they want in the start , just keep practicing and you will do it easily. Good Luck :) . Feel free to ask any queries.
If the solution worked for you , please mark it solved :)
Sergey Alexandrovich Kryukov 25-Sep-13 16:30pm    
Agree... I also recommend to accept the solution formally.
—SA
Sergey Alexandrovich Kryukov 25-Sep-13 16:30pm    
Of course, absolutely nothing wrong with that, but I would just advise to get familiar, in particular, with liquid, fluid and elastic design...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900