html - 显示 :table 的元素内表格的限制宽度

标签 html css

我有一个在 CSS 中设置为 display:table 的 div。当我在其中放置一个实际的 table 时,我想水平滚动它,外部 div 脱离 container 并扩展到页面宽度。谁能帮我解决这个问题?

我试图将容器保持在固定宽度,不滚动。我只想让表格滚动的 div。

JSFIDDLE: http://jsfiddle.net/c0996dqe/

CSS:

.container{
    width:500px;
}
.answer{
    display: table;
    padding-bottom: 25px;
    border-bottom: 1px dotted #ccc;
    overflow: hidden;
}
.answer:before{
    display: table-cell;
    width: 5%;
    content: "A";
    font-size: 30px;
    height: 100%;
    padding-right: 25px;
}
.scorestable{
    display: block;
    white-space: nowrap;
    overflow-x: scroll !important;
    -webkit-overflow-scrolling: touch;
    padding-top: 25px;
}
.scorestable td{
    border: 1px solid #ccc;
    padding: 5px;
    min-width: 65px;
    text-align: center;
    font-size: 14px;
}

最佳答案

将这些样式添加到 .answer:

.answer {
  table-layout: fixed;
  width: 100%;
}

Fiddle

关于html - 显示 :table 的元素内表格的限制宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30490311/

相关文章:

javascript - AngularJS 中的复杂表单验证

javascript - 如何从json构建带有连接线的框

javascript - ionic 导航 - 不要更新导航栏

html - div 内 100% 宽度的输入与 div 重叠

html - CSS 选择要打印的内容(媒体查询)

html - 应用媒体查询时,没有任何调整

javascript - 如何在html上向左滚动?

html - 更改 Bootstrap 导航链接填充而不会弄乱对齐

css - WP7 :before and :after

html - 无法单击导航栏中的链接