码迷,mamicode.com
首页 > 其他好文 > 详细

关于position

时间:2018-09-27 14:21:12      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:lin   style   相对   isp   网页   1.0   viewport   doc   关于   

有四个属性:  

static:静止
relative:相对的
fixed:固定的(广告等信息固定在网页的某个位置,不管你上下滑动位置不变)
absolu:绝对的

.box{
display:inline-block;
width: 100px;
height: 100px;
background: blue;
color: rgb(71, 16, 16);
}


#two {
position: fixed;
top: 200px;
left: 100px;
background: red;
}


#one{
position: absolute;
top: 1000px;
left: 10px;
background: black;

}
 
#three{
position: sticky;
top: 200px;
left: 80px;
background: purple;


}

  

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="positionCSS.css">
</head>
<body>
    <div class="box" id="one">one</div>
    <div class="box" id="two">two</div>
    <div class="box" id="three">three</div>
    <div class="box" id="four">four</div>
</body>
</html>

  

 

 

关于position

标签:lin   style   相对   isp   网页   1.0   viewport   doc   关于   

原文地址:https://www.cnblogs.com/Jason1/p/9712491.html

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