使div扩展溢出

时间:2013-08-13 20:31:10

标签: html css html5 css3

所以我有这种html

<div class="table-container">
  <div class="title"> Title </div>  
  <table>
  </table>
</div>

.table-container {
  font-family: 'BlenderPro';
  overflow-x: scroll;
  padding-bottom: 20px;
  margin-bottom: 40px;
  margin-right: auto;
  background: #ffffff;
}

.title {
  font-family: 'RobotoMedium';
  font-size: 1.5em;
  font-weight: normal;
  margin-bottom: 10px;
  padding-bottom: 10px;
  padding-left: 5px;
  padding-top: 15px;
  text-align: left;
  color: #ffffff;
  background: #3a3a3d;
  border: 1px solid #ffffff;
}

现在,问题是我的标题没有随表扩展。所以当有溢出并且我向右滚动时,标题在我滚动时不会“跟上” - 标题的宽度比表格容器的宽度窄。

为什么以及如何将其扩展到该宽度?

2 个答案:

答案 0 :(得分:0)

将标题的宽度设置为100%。

答案 1 :(得分:0)

标题的样式应将宽度设置为其父级的100%。这可以通过将您的css文件更改为:

来完成
.table-container {
  font-family: 'BlenderPro';
  overflow-x: scroll;
  padding-bottom: 20px;
  margin-bottom: 40px;
  margin-right: auto;
  background: #ffffff;
}

.title {
  font-family: 'RobotoMedium';
  font-size: 1.5em;
  font-weight: normal;
  margin-bottom: 10px;
  padding-bottom: 10px;
  padding-left: 5px;
  padding-top: 15px;
  text-align: left;
  color: #ffffff;
  background: #3a3a3d;
  border: 1px solid #ffffff;
  width: 100%;
}
相关问题