屏幕分辨率问题
在对索引页进行编码后,我遇到了这个问题。我已将页面分为两列:
header
nav
content floating left, content floating right
footer
在我的屏幕分辨率上,我将其正确对齐:
Content left | Content right
但在小屏幕上,它看起来像这样:
Content left
Content right
这是代码:
<div id="contentleft">
text & content left
</div>
<div id="contentright">
text & content right
</div>
CSS:
#contentleft {
float:left;
margin-left:12%;}
#contentright {
float:right;
margin-right:12%;}
帮助将非常有用
I have this problem after coding my index page. I have divided the page into 2 columns:
header
nav
content floating left, content floating right
footer
On my screen resolution I have it properly aligned:
Content left | Content right
But on a small screen, it looks like this:
Content left
Content right
This is the code:
<div id="contentleft">
text & content left
</div>
<div id="contentright">
text & content right
</div>
CSS:
#contentleft {
float:left;
margin-left:12%;}
#contentright {
float:right;
margin-right:12%;}
Help would be great appriciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当没有足够的空间容纳浮标时,浮标将换行。你的CSS的宽度设置为自动扩展到内容。
floats will wrap when there does not exist enough space for them. your css has the width set to auto expand to the content.
防止重叠的一种方法是将两个
div
放置在#wrapper div
中,并为#wrapper
设置一个width< /代码>。
示例: http://jsfiddle.net/jasongennaro/b2eyx/1/< /a>
仅供参考...我还将它们都向左浮动并更改了边距并添加了一些颜色以使其更易于查看。
欢迎来到 SO!
One way to prevent the overlap is to place both
div
s in a#wrapper div
and give the#wrapper
a setwidth
.Example: http://jsfiddle.net/jasongennaro/b2eyx/1/
Fyi... I also floated them both left and changed the
margin
s and added some color to make it easier to see.And welcome to SO!
将
width
添加到您的 Div 中,并将其放入 %(如 50%-50%)中。add
width
to your Divs and put it in % like 50%-50%.