首页 > Web开发 > 详细

css position设置

时间:2015-12-01 21:19:11      阅读:293      评论:0      收藏:0      [点我收藏+]

一:相对定位 relative

relative生成相对正常位置进行定位;例如“left:20”会向left位置添加20像素;

     注意:margin-left属性不能使用。

h2.pos_right
{
position:relative;
left:200px
}/*相对正常位置向右移动200像素*/

二:绝对定位 absolute

 absolute 生成绝对元素,相对于默认值定位以外的第一个父元素进行定位

注意:通过绝对定位,元素可以放置在界面任何位置

 h2.pos_abs
{
position:absolute;
left:100px;
top:150px
}/*相对父元素*/

三:固定位置fixed

fixed相对浏览器窗口对元素进行定位。

 p.two
{
position:fixed;
top:30px;
right:5px;
}

四:设置元素形状

<html>
<head>
<style type="text/css">
img 
{
position:absolute;
clip:rect(0px 50px 200px 0px)
}
</style>
</head>
<body>
<p>clip 属性剪切了一幅图像:</p>
<p><img border="0" src="/i/eg_bookasp.gif" width="120" height="151"></p>
</body>
</html>

 

css position设置

原文:http://www.cnblogs.com/shineda/p/5011179.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!