html – 如何对齐2相邻的divs水平无浮点?

前端之家收集整理的这篇文章主要介绍了html – 如何对齐2相邻的divs水平无浮点?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想让两个div彼此相邻,以便在没有FLOAT的同一个水平线上对齐

我已经尝试了位置:亲戚,但没有运气

见下面的例子:
http://jsfiddle.net/XVzLK

@H_502_7@<div style="width:200px;height:100px;background:#ccc;"> <div style="background:Blue; float:left; width:100px; height:100px;"></div> <div style="background:red; float:left; margin-left:100px; width:100px; height:100px;"></div> </div>

从上面的链接,我需要红色框在同一行的蓝色框,没有空格下面..

编辑:我想要红色的盒子留在容器的灰色框之外(就像这样)谢谢

解决方法

当您的高度和宽度固定时,请使用“位置”属性 @H_502_7@<div style="width:200px;height:100px;position:relative;background:#ccc;"> <div style="background:Blue; position:absolute; left:0%; width:50%; height:100%;"> </div> <div style="background:red; position:absolute; left:50%; width:50%; height:100%;"> </div> </div>
原文链接:https://www.f2er.com/html/224478.html

猜你在找的HTML相关文章