CSS 以相反顺序水平放置 Div
我有一个看起来像
<div id="content">
<p> blah </p>
</div>
<div id="menu">
<p> blah2 </p>
</div>
<div id="footer">
<p> Copyright </p>
</div>
内容 div 位于菜单 div 之后的文档,但是是否可以像这样显示布局:
-------------------
| Menu | Content |
| | |
| | |
-------------------
| Footer |
-------------------
如何交换它们的顺序?我宁愿不使用绝对定位。
I have a document that looks like
<div id="content">
<p> blah </p>
</div>
<div id="menu">
<p> blah2 </p>
</div>
<div id="footer">
<p> Copyright </p>
</div>
The content div is after the menu div, but is it possible to have the layout displayed like so:
-------------------
| Menu | Content |
| | |
| | |
-------------------
| Footer |
-------------------
How do you swap their order? And I'd rather not use absolute positioning.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
float:right/float:left 解决方案的一个问题是您必须处理的元素之间的间隙,以及额外的容器 div。
另一种方法是:
其中 500px 是内容的宽度,100px 是菜单的宽度。该解决方案需要相对定位和固定宽度的 div。
One problem with the float:right/float:left solutions is the gap between the elements you have to take care of, plus the extra container div.
Another way to do it is:
Where 500px is the width of the content, and 100px is the width of the menu. That solution requires relative positioning and fixed width divs.
尝试一些像这样的CSS:
Try some css like this:
对它们中的每一个尝试
float:right;
。try
float:right;
on each of them.我会在菜单和内容上进行浮动,然后在将宽度设置为 100% 后在页脚上清除两者。
I would do the float right on menu and content then a clear both on the footer after setting the width to 100%.
你能改变 HTML 代码吗?如果可能的话,我会这样做:
并将其样式设置为:
我猜你不能,因此你会问,那么我会按照其他人的说法做:
Can you alter the HTML code, if that is possible I would do:
And style it with:
I guess you cant and it is therefore you ask, then I would do as the others say: