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

CSS布局

时间:2016-03-28 21:54:20      阅读:351      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

@charset "UTF-8";
/* CSS Document */


body{
    margin:100px;
    height:800px;
    border:1px solid red;
}
/*绝对定位*/
header
{ width:100px; height:100px; background-color:gray; position:absolute;
/*绝对位置,脱离文档空间,在z轴上浮空*/ top:0px; left:0px; z-index:1;
/*数字越大,层次越高,auto默认层次*/ } aside{ width:100px; height:100px; background-color:yellow; position:absolute; top:20px; left:20px; }
<!doctype html>
<html lang="zh-cn">
<head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="123.css" type="text/css">
      <title>css传统布局</title>
</head>
<body>
<header>
    header
</header>

<aside>
    aside
</aside>
树懒啊闪电
</body>

</html>

 

------------gegegegegegeg---------

 

 

 

 

技术分享

@charset "UTF-8";
/* CSS Document */

body{
    margin:100px;
    height:800px;
    border:1px solid blue;
    position:relative;
    
}

header{
    width:100px;
    height:100px;
    background-color:green;
    position:absolute;
    top:10px;
    left:10px;
    
<!doctype html>
<html lang="zh-cn">
<link rel="stylesheet" href="CSS定位.css" type="text/css">
<head>
<meta charset="UTF-8">
<title>某点的绝对定位</title>
</head>

<body>

<header>
     herder
</header>
闪电

</body>
</html>

------------gegegeggegegegegegegge---------------

技术分享

@charset "UTF-8";
/* CSS Document */

body{
    margin:100px;
    width:500px;
    height:800px;
    border:1px solid blue;
    
}
header{
    width:100px;
    height:100px;
    background-color:green;
    position:fixed;
    top:100px;
    left:0px;
}
/*以窗口左上角为基准点定位,不占位,header随窗口移动*/
<!doctype html>
<html lang="zh-cn">
<link rel="stylesheet" href="以窗口定位.css" type="text/css">
<head>
<meta charset="UTF-8">
<title>窗口定位</title>
</head>

<body>

<header>
     herder
</header>


</body>
</html>

---------------gegegeggegegegegegegeg--------------------

 

技术分享

@charset "UTF-8";
/* CSS Document */
body{
    width:960px;
    margin:0 auto;
    position:relative;
}

header{
    height:120px;
    width:960px;
    background-color:olive;
    position:absolute;
    resize:both;     
/*允许调节宽和高,表单元素textarea默认允许更改元素尺寸,而普通元素需要设置overflow*/
    overflow:auto;
    z-index:1;
}

textarea{
    resize:none;     /*默认不可以拖动调整大小*/
}

aside{
    width:200px;
    height:500px;
    border:5px solid blue;
    box-sizing:border-box;  
/*    border-box使border和padding不再额外增加元素的大小,设置后不用于元素总长度
*/    background-color:red;
    position:absolute;
    top:120px;
    left:0px
}
section{
    width:760px;
    height:500px;
    background-color:yellow;
    position:absolute;
    top:120px;
    right:0px
}
footer{
    width:960px;
    height:100px;
    background-color:green;
    position:absolute;
    top:620px;
    
}

 

<!doctype html>
<html lang="zh-cn">
<link rel="stylesheet" href="布局.css" type="text/css">
<head>
<meta charset="UTF-8">
<title>绝对定位的布局</title>
</head>

<body>

<header>
     herder
</header>
<aside>
aside
</aside>
<section>
section
    <textarea name="123" id="aaa" cols="30" rows="10"></textarea>
</section>
<footer>
footer
</footer>


</body>
</html>

 

CSS布局

标签:

原文地址:http://www.cnblogs.com/webday/p/5330557.html

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