html - How to put div block into right screen area using css? -


i created simple web page layout includes : header, left, right , footer div blocks.

this html code:

<html>     <head>         <title>test page</title>         <link rel="stylesheet" type="text/css" href="css/style.css">     </head>     <body id="body">         <div class="header">             <p>header</p>         </div>         <div class="left">             <div class="article">                 <p>article 1</p>             </div>             <div class="article">                 <p>article 2</p>             </div>             <div class="article">                 <p>article 3</p>             </div>         </div>         <div class="right"></div>         <div class="footer">             <p>footer</p>         </div>     </body> </html> 

this css style :

body {     margin: 0px; }  .header {     width: 1200px;     height: 100px;     border-style: solid;     border-color: black;     border-width: 5px;     border-radius: 3px; }  .left {     margin-top: 5px;     width: 1000px;     border-style: solid;     border-color: black;     border-width: 5px;     border-radius: 3px; }  .article {     margin: 50px;     height: 400px;     border-style: solid;     border-color: green;     border-width: 5px;     border-radius: 3px; }  .footer {     margin-top: 5px;     width: 1200px;     height: 100px;     border-style: solid;     border-color: black;     border-width: 5px;     border-radius: 3px; }  p {     text-align: center; } 

the web page looks this: enter image description here

but when try add left block on picture looks uncorrect. use css code that:

.right {     margin-top: 5px;     width: 200px;     border-style: solid;     border-color: black;     border-width: 5px;     border-radius: 3px;     float: right; } 

demo on jsfiddle - http://jsfiddle.net/khbtg/

how can put left div block in yellow area on picture? thank help.

you want float .right right. if can change markup to:

<div class="header">#header</div> <div class="container">     <div class="right">         <div class="nav">#nav</div>     </div>     <div class="content">         <div class="article">#article</div>         <div class="article">#article</div>         <div class="article">#article</div>     </div> </div> <div class="footer">#footer</div> 

you want add styles:

.container { clear: both; }  .content { width: 80%; }  .right {      width: 20%;     float: right;   }  .content, .right {     margin: 0;     padding: 0; } 

fiddle: http://jsfiddle.net/ydnsa/1/. added .container clear things, don't want float around .header or .footer. remember avoid putting margin, padding or border on .right or .content.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -