摘要:
下文讲述使用css脚本使元素靠左或靠右对齐,如下所示:
实现思路:
使用position:absolute 相对父级元素的定位,
然后使用right:0px 或 left:0px 靠左或靠右定位的方式
使元素靠左或靠右
例:
元素靠左 靠右定位举例
.divAll
{
background-color:black;
width:400px;
height:400px;
color:white;
position:absolute;
left:0px;
top:10px;
}
.right {
position: absolute;
right: 0px;
width: 100px;
border: 3px solid white;
padding: 10px;
}
.left{
position: absolute;
left: 0px;
width: 100px;
border: 3px solid white;
padding: 10px;
}
右对齐和左对齐演示
左对齐举例
右对齐举例
css 左对齐 右对齐的方法