我们在设置盒子样式或者位置的时候会遇到margin-right没有效果。要怎么解决呢?首先要观察一下设置margin-right的元素有没有设置width属性,width的属性值是什么。
当没有设置width时,width默认为auto:
这时的margin-right是正常显示的;
当width设置为固定值或者百分比时:
margin-right在默认文档标准流中是无效的,要想显示出效果,必须要脱离文档标准流,可以用下面的方法恢复margin-right的效果:
float:left | right;
设置position;
设置display;
一:定位
margin-bottom是指该元素与其后的兄弟节点之间的距离。如果你在m1下面再加上一行p标签,你会看到,p距离m1之间的距离,就是m1的margin-bottom的值。最外层那个id为box的div,是m1的父级节点,m1的margin-bottom是不会对box产生效果的。
如果要使一个节点相对于某个节点固定在指定位置,应该是bottom(以及top、left和right)属性,但这个要求该节点的position属性是absolute(即绝对定位),且其父节点的position属性为relative(相对定位),则该几点即可相对其父节点定位。比如:
相对父节点定位
二:给父节点一个margin-bottom也可间接实现
给父级设置:
margin-right: 0px;
overflow:hidden;
zoom:100%;
.panel-item{
margin-right: 0px;
overflow:hidden;
zoom:100%;
}
#cont table{
width: 100%;
height: 100%;
margin-top: 10px;
margin-left: 12px;
margin-bottom: 12px;
background-color: papayawhip;
}
可能是浏览器默认是从左向右渲染
一个div .box默认是左上对齐,所以margin-right、margin-bottom设置不起作用
鼠标靠近显示图片,离开隐藏

//在li标签中直接用img无效果,暂时没找到原因,所以用的背景图代替
<div class="hover">
<ul class="ul-one">
<li class="li li-one"></li>
<li class="li li-two"></li>
<li class="li li-three"></li>
</ul>
</div>
.hover{
position: absolute;
right: 0px;
top: 0px;
height: 100%;
}
.ul-one {
margin-top: 24px;
}
.hover li {
margin: 8px 0px;
width: 26px;
height: 20px;
}
.hover .li-one:hover{
background: url('../../images/monitor/tip.png') no-repeat 5px 0px;
background-color: #D9E7FF;
border-top-left-radius: 1em;
border-bottom-left-radius: 1em;
}
.hover .li-two:hover{
background: url('../../images/monitor/time.png') no-repeat 5px 0px;
background-color: #D9E7FF;
border-top-left-radius: 1em;
border-bottom-left-radius: 1em;
}
.hover .li-three:hover{
background: url('../../images/monitor/echart.png') no-repeat 5px 0px;
background-color: #D9E7FF;
border-top-left-radius: 1em;
border-bottom-left-radius: 1em;
}