展开全部
html 让其中一个div浮在另一个div上面 通常情况下,有两种实现方法:(1) 浮动62616964757a686964616fe4b893e5b19e31333366306461的元素设置float属性 (2) 浮动的元素设置position属性为 absolute, 另一个元素设置position属性为 relative。
具体实现代码如下:
1、设置float属性
.dom1 { position: relative; width: 150px; height: 150px; background: #00f; }
.dom2 { position: absolute; top: 0;width: 100px; height: 100px; background: #999; }
运行结果为:
2、浮动的元素设置position属性为 absolute, 另一个元素设置position属性为 relative
.dom1 { position: relative; width: 150px; height: 150px; background: #00f; }
.dom2 { position: absolute; top: 0;width: 100px; height: 100px; background: #999; }
运行结果为:
扩展资料:
CSS float的作用:
Float浮动用于设置对象靠左与靠右浮动样式,可以实现我们所需要的让DIV、SPAN等标签居左居右浮动。
代码示例如下:
.divcss5{ width:400px;padding:10px;border:1px solid #F00}
.divcss5_left{ float:left;width:150px;border:1px solid #00F;height:50px}
.divcss5_right{ float:right;width:150px;border:1px solid #00F;height:50px}
.clear{ clear:both}
运行效果为: