模型

2018-03-23  本文已影响0人  Wonder茂茂

盒子模型


层模型

定位元素:绝对定位和相对定位

position:absolute

脱离原来位置进行定位,原来位置为空。

相对于最近的有定位的父级定位,如果没有父级定位,那么就相对于文档定位。 

position:relative

保留原来位置进行定位,依然占原来位置,只是相对原来位置变化。

相对于自己原来的位置定位。


广告定位

position:fixed

侧面广告

<style>

div{

position:fixed;left:0;top:300px;width:50px;height:300px;background-color:red;

}

</style>

<body>

<div>广告</div>

</body>


居中广告

<style>

div{

position:fixed;left:50%;top:50%;width:100px;height:100px;background-color:red;

margin-left:-50px;margin-top:-50px;

}

</style>

上一篇 下一篇

猜你喜欢

热点阅读