html - 100% 宽度弄乱了填充

标签 html css padding

.SalesPanel 类中,我已将其设置为 100% 宽度。我注意到它重叠了我在 content id 中设置的右边的填充。

参见:http://jsfiddle.net/CBAE7/9/并查看右侧填充并将其与左侧填充进行比较。

是什么原因造成的以及如何解决?

即使使用 100% 宽度,我也期待 1 行有 3 个 div。如何解决?

HTML:

<div id='content'>
  <div class='SalesPanel'> One </div>
  <div class='SalesPanel'> Two </div>
  <div class='SalesPanel'> Three </div>
</div>​

CSS:

#content {
  width: 700px;
  padding: 8px;
  overflow: hidden;
  background-color: white;
  border: 1px solid #C8CCD5;
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
  border-radius: 4px;
}

.SalesPanel {
  border:1px solid #dddddd;
  height:30px;
  float:left;
  width: 100%
}
​

最佳答案

试试这个 jsFiddle example .

#content {
  width: 700px;
  padding: 8px;
  background-color: white;
  border: 1px solid #C8CCD5;
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
  border-radius: 4px;
}
.SalesPanel {
  border:1px solid #dddddd;
  height:30px;
  width: 33%;
  display:inline-block;
  margin:0;
}​

关于html - 100% 宽度弄乱了填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12656082/

相关文章:

css - 什么是 CSS 中的像素 (px)(在视网膜显示时代)?

css - 为什么 IE7 无法识别 anchor 标记上的 css 填充样式?

html - 为什么 anchor(<a ) 样式为 :visited color applies to all the anchor tags in Mozilla Firefox?

javascript - 返回我在 HTML 表单中键入的文本

html - 具有输入焦点的 iPad 固定位置

javascript - 如何在点击移动设备时更改横幅位置?

html - css 更改复选框和单选按钮不显示任何内容

javascript - 使用显示 : none visible again + Loading Image before <li> 制作 HTML Div

html - 显示 : table: increasing height of a table cell causes padding in other cells

html - 用于 html 表格填充的内联 css