【问题标题】:Table width issue, html css表格宽度问题,html css
【发布时间】:2018-11-22 15:52:04
【问题描述】:

我在 CHROME & SAFARI 中制作了一个表格,该表格没有填满父 div 的整个宽度。

这在 Firefox 中运行良好,但我想在所有浏览器中运行。

在这里查看了一些视图后,我发现在某些 chrome 情况下可以通过将父 div 设置为...来修复...

display: block; width: 100%;

.. 但问题仍然存在。

还发现了另外几个没有指定边距和填充的情况,因此试了一下,但在 Chrome 和 Safari 中显示仍然存在问题。

HTML

<div class='player_box info_pic_2'> 
    <div style='display: block; width: 100%;'>
        <table style='margin: 0; padding: 0; width: 100%; border-style: solid; border-width: 1px; position: absolute; left: 0; top: 0; right: 0px; height: 30px;'>
                <tr class='border_bottom'>
                    <td>CELL A</td>
                    <td>CELL B</td>
                </tr>
        </table>
        <table style='margin: 0; padding: 0; width: 100%; border-style: solid; border-width: 1px; position: absolute; left: 0; right: 0px; top: 30px;'>
            <tr class='border_bottom'>
                <td>ROW A </td>
            </tr>
            <tr class='border_bottom'>
                <td>ROW B </td>
            </tr>
            <tr class='border_bottom'>
                <td>ROW C </td>
            </tr>
            <tr class='border_bottom'>
                <td>ROW D </td>
            </tr>
            <tr class='border_bottom'>
                <td>ROW E </td>
            </tr>
            <tr class='border_bottom'>
                <td>ROW F </td>
            </tr>
        </table>
    </div>
</div>

CSS

tr.border_bottom td {
    border-bottom:1pt solid black;
}
.info_pic_2 {
    position: absolute;;
    height: 250px;
    top: 130px;
    right: 70px;
    width: 350px;
    max-width: 100%;
    display: block;
    border-style:solid;
    border-width:5px;
    color: black;
}
.player_box {
    border:solid 4px #000000;
    -moz-border-radius-topleft: 33px;
    -moz-border-radius-topright:32px;
    -moz-border-radius-bottomleft:32px;
    -moz-border-radius-bottomright:32px;
    -webkit-border-top-left-radius:33px;
    -webkit-border-top-right-radius:32px;
    -webkit-border-bottom-left-radius:32px;
    -webkit-border-bottom-right-radius:32px;
    border-top-left-radius:33px;
    border-top-right-radius:32px;
    border-bottom-left-radius:32px;
    border-bottom-right-radius:32px;
    text-align:center; background:#575757;
    padding:100px 50px 100px 50px;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
    opacity: 0.8;
}

【问题讨论】:

标签: html css html-table


【解决方案1】:

您的问题似乎是您的 .player_box 选择器中的 padding 值(CSS 上倒数第二行。删除填充,它将正确填充。

【讨论】:

  • 不用担心!也只是一个有用的提示,我尽量将我的样式保留在 css 中。当我在一个地方寻找这些小东西时,要容易得多!此外,它也让 SO 上的人们更容易在这里提供帮助。
【解决方案2】:

我可以通过改变这个 CSS 让它表现得更好:

.info_pic_2 {
    position: absolute;
    height: 250px;
    top: 130px;
    right: 70px;
    width: 350px;
    max-width: 100%;
    display: block;
    border-style: solid;
    border-width: 5px;
    color: black;
}

到:

.info_pic_2 {
    height: 250px;
    top: 130px;
    right: 70px;
    max-width: 100%;
    display: block;
    border-style: solid;
    border-width: 5px;
    color: black;
}

我发现混合绝对定位和百分比宽度是一场噩梦。

编辑:填充也无济于事,但请在此处查看我的更新版本:

http://jsfiddle.net/rcQmW/2/

【讨论】:

  • 干杯,对这种情况没有帮助,发现我在 #player_box css 中有填充值,这导致了问题。感谢您的帮助
猜你喜欢
  • 2013-09-04
  • 2015-08-11
  • 1970-01-01
  • 2017-01-30
  • 2014-02-02
  • 1970-01-01
  • 1970-01-01
  • 2012-05-09
  • 2012-10-10
相关资源
最近更新 更多