复习-css元素定位

复习-css元素定位

css元素定位

 

<style type="text/css">
body{
    margin: 15px;
    font-family: "Adobe 宋体 Std L";
    font-size:12px;
}
.father{
    background-color: black;
    border: 1px solid #111111;
    padding: 25px;
}
.son{
    padding: 10px;
    margin:5px;
    background-color: aliceblue;
    border:1px dashed;
    float:left;
}
.son2{
    padding: 5px;
    margin: 0px;
    background-color: #111111;
    border:1px dashed #111111;
}
</style>


<style type="text/css">
body{
    margin: 5px;
    font-family: "Adobe 宋体 Std L";
    font-size: 13px;
}
.block1{
    padding-left:10px;<!--列距--> 
    margin-right:10px;
    float:left;<!--浮动在左边上层-->
}
.h3{
    background-color: aliceblue;;
    border: 1px dashed #233333;
    clear:left;<!--清除浮动-->
}
</style>


<style type="text/css">
#block{
    background-color: ];
    border:1px dashed #000000;
    padding: 10px;
    position:absolute;<!--绝对定位,脱离了父标签-->
    <!--position:relative<!--相对于自身原来的距离,在父块-->
    left:20px;<!--相对于页面body的距离-->
    top:40px;
}
</style>


<body>
<div id = "father">
    <div id = "block">absolute</div>
    <div id = "block1">relative</div>
</div>
</body>

 

z-index调整定位时重叠块的上下而为之,当块设置了position属性时,该值便可设置各块之间的重叠高低关系,默认值为0

<style type="text/css">
#block1{
    ... position: absolute;
    left: 20px;
    top:20px;
    z-index: 1;<!--高低值-->
}
#block2{
    ... position: absolute;
    left:10px;
    top:23px;
    z-index: 0;<!--高低值0-->
}
</style>

 

 

posted @ 2018-04-02 11:09 Edge_of_Eternity 阅读(...) 评论(...) 编辑 收藏

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值