Table width 100% is off by a single pixel (depending on actual width)

前端 未结 3 1500
轻奢々
轻奢々 2021-02-14 03:12

I have a table in a div inside another div. The direct container has a width of 40%, and I want the table to be as wide as th

3条回答
  •  耶瑟儿~
    2021-02-14 03:37

    The error replicates here for me on CHROME.

    I inspected the element, and what I noticed is, the width of the table box was 217.443 px (obviously due to the % widths)

    in the inspect element HTML section, it defines the width of the table as 218 px, and the containing div as 217px..

    When I expand the broswer window slightly, thus making the table width increase past 217.443 px, to 217.680 px,

    the HTML section displays BOTH the table width and the containing div as 218 px.

    so im guessing the browser is rounding the pixels off to the nearest whole pixel.

    could this be the right route to investigate?

    edit: Try this and see if this works for you. I have fixed the problem (I think) in this jfiddle

    http://jsfiddle.net/E2mUQ/3/

    I simply removed the width on the .table class, and relaced it with DISPLAY:block

提交回复
热议问题