码迷,mamicode.com
首页 > Web开发 > 详细

css负边距布局

时间:2015-07-02 23:55:56      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:

负边距布局
<!DOCTYPE html>
<html>
<head>
    <title>负边距布局</title>
    <meta charset="utf-8">
       <style type="text/css">
          .container 
{ 
                      overflow
: hidden; 
                   
}
          .wrap  
{   
                      width
: 100%; float: left; 
                   
}
          .body  
{   
                      background
: red;
                      margin-left
: 120px;
                      margin-right
: 150px;
                     
}
          .left 
{   
                      background
: green;
                      margin-left
:-100%;
                      float
:left;
                      width
: 120px;
                     
}
          .right 
{   
                       background
: yellow;
                       margin-left
: -150px;
                       float
: left;
                       width
: 150px;
                     
}
        
</style>
        <style type="text/css">
         .container1 
{
                     border
: solid 1px red; 
                     width
: 200px; 
                     height
: 200px; 
                     position
:relative;
                   
}
         .block  
{ 
                    width
: 100px; 
                    height
: 100px; 
                    float
: left; 
                    background
: yellow; 
                    margin-left
: -50px; 
                    margin-top
: -50px; 
                    position
: absolute; 
                    top
:50%;
                    left
:50%;
                  
}
         .container2 
{
                      overflow
: hidden;
                    
                    
}       
         .item   
{
                     float
: left;
                     width
: 50px;
                     background
: lime;
                     margin-right
: 10px;
                     padding-bottom
: 100px;
                     margin-bottom
: -100px;
                  
}
        
</style>
</head>
<body>      
       <hr>
      <p>三列布局:</p>
      <p>&nbsp;</p>
      <div class="container">
         <div class="wrap">
         <div class="body">center</div>
      </div>
         <div class="left">left</div>
         <div class="right">right</div>
      </div>
      <hr color="red" />
  <div>
        <p>绝对定位元素</p>
        <div class="container1">
        <div class="block"></div>
  </div>
     <p>&nbsp;</p>
     <hr/>
         <div class="container2">
            <p>等高布局</p>
            <div class="item">123</div>
            <div class="item">234<br/>345<br/>456<br/></div>
            <div class="item">467</div>
         </div>     
</body>
</html>

三列布局:

 

center
left
right

绝对定位元素

 


等高布局

123
234
345
456
467

css负边距布局

标签:

原文地址:http://www.cnblogs.com/liurenxingyu/p/4617115.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!