<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 4 年前。
<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 4 年前。
困扰了我很多天,针对这些问题问了几个相关的问题。我的主要问题是如何阻止我的 div 溢出。我刚刚设法解决了将它们换到另一条线上的问题。
这里是 a fiddle .
这是一个片段:
#main-content {
padding: 0% 15% 0% 15%;
overflow: hidden;
height: 620px;
clear: both;
width: 70%;
border-style: solid;
border-color: #31679a;
border-width: 0px 0px 2px 0px;
}
#side-bar {
float: left;
max-width: 28%;
height: 99%;
padding: 1% 1% 0% 1%;
font-size: 14px;
}
#container {
float: left;
max-width: 68%;
height: 100%;
padding: 1% 1% 0% 1%;
}
主要内容包含侧边栏和容器,它们并排放置(侧边栏在左侧)
您可以在主要内容区域中看到,容器以一定的宽度与侧边栏重叠,而不是停在它的边缘。标题中的图像也会发生这种情况,但不会显示在 fiddle 中。
如果有任何帮助,我将不胜感激。
最佳答案
作为快速修复,将以下代码添加到您的 CSS 将阻止链接换行:
#sidebar a {
white-space: nowrap;
}
然而,您真正的问题是您的侧边栏 div 不够宽,无法包含其内容。
您还应该使用 div 而不是表格来进行布局:阅读原因 here .
关于html - div溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21753286/