<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    我是FE,也是Fe

    前端來源于不斷的點滴積累。我一直在努力。

    統(tǒng)計

    留言簿(15)

    閱讀排行榜

    評論排行榜

    mark:webkit表格設(shè)置css table-layout:fixed的bug

    通常使用table-layout:fixed用在表格上來使表格能準確的設(shè)置寬度。常見的例子莫過于
        <style type="text/css">
            table
    {table-layout:fixed; border-collapse:collapse;border:1px solid #000; border-width:1px 0px 0px 1px;width:200px;}
             td
    {text-align:left;overflow:hidden;padding:0px;margin:0px;white-space:nowrap; border:1px solid #000; 0px 1px 1px 0px;}
        
    </style>
        
    <table  border="0" cellspacing="0" cellpadding="0">
            
    <tr>
                
    <td style="width:100px;" nowrap="nowrap" >中文中文阿飛的房間薩芬;撒</td>
                
    <td style="width:100px;" nowrap="nowrap" >saaaa</td>
            
    </tr>
        
    </table>

    如果去掉table-layout:fixed,表格的寬度會根據(jù)內(nèi)容自動調(diào)整,比如上面的例子,如果去掉table-layout:fixed。第一個單元格的寬度會超過100px;
    但是最近發(fā)現(xiàn),使用table-layout:fixed在webkit內(nèi)核瀏覽器上(safari/chrome)。寬度顯示會出現(xiàn)問題。
    看看下面的例子:
     <style type="text/css">

                

            #test

            
    {

                border-collapse
    :collapse;

            
    }

            

            #test td, #test th

            
    {

                border
    :solid 1px black;

                padding
    :3px;

            
    }



        
    </style>

    <table style="width:736px;table-layout:fixed;margin:0;padding:0" id="test">

            
    <thead>

                
    <tr>

                    
    <th width="25">ID</th>

                    
    <th width="270">Name</th>

                    
    <th width="54">xx</th>

                    
    <th width="54">xx</th>

                    
    <th width="54">xx</th>

                    
    <th width="54">xx</th>

                    
    <th width="54">xx</th>

                    
    <th width="54">xx</th>

                    
    <th width="54">xx</th>

                
    </tr>

            
    </thead>

            
    <tbody>

                
    <tr>

                    
    <td>111</td>

                    
    <td></td>

                    
    <td>&nbsp;</td>

                    
    <td>&nbsp;</td>

                    
    <td>&nbsp;</td>

                    
    <td>&nbsp;</td>

                    
    <td>&nbsp;</td>

                    
    <td>&nbsp;</td>

                    
    <td>&nbsp;</td>

                
    </tr>

            
    </tbody>

        
    </table>

    瀏覽器上的截圖為:


    搜了一番資料后。在webkit官網(wǎng)上有這么一個Bug

    If a table has both "table-layout: fixed" and "width: 0", then cells with
    borders have wrong width.
    This occurs in both safari 3.x mac&win and linux svn 31841 (debian sid).
    The expected behavior is rendered by IE6, IE7, Firefox 2, Firefox 3 beta and
    Opera 9.2.
    
    Consider a table with 3 columns, all with width 200px.
    If one of the cells have "border-left: 50px; width: 150px;",
    then according to the rules of "table-layout: fixed", the cell should still
    have width 200px.
    But webkit renders the cell with only width 150px.


    就是設(shè)置了table-layout:fixed之后,table的td寬度style.width不再是內(nèi)容的寬度,而是內(nèi)容+邊框。而且是忽視padding。這讓人很郁悶。
    總之一旦設(shè)置了table-layout:fixed之后,webkit瀏覽器的單元格寬度并不會像你想象的那樣準確的寬度。

    參考資料:
    webkit的bug描述:
    https://bugs.webkit.org/show_bug.cgi?id=13339
    https://bugs.webkit.org/show_bug.cgi?id=18565
    stackoverflow的提問:
    http://stackoverflow.com/questions/2943369/table-layoutfixed-rendering-differences-in-safari

    http://lists.macosforge.org/pipermail/webkit-unassigned/2008-April/071125.html







    posted on 2011-06-30 18:39 衡鋒 閱讀(1834) 評論(1)  編輯  收藏 所屬分類: Web開發(fā)

    評論

    # re: mark:webkit表格設(shè)置css table-layout:fixed的bug 2012-07-02 12:17 hafeyang

    此bug,webkit已經(jīng)修復(fù) https://bugs.webkit.org/show_bug.cgi?id=78412  回復(fù)  更多評論   

    主站蜘蛛池模板: 99re热精品视频国产免费| 亚洲香蕉免费有线视频| 99re热免费精品视频观看| 日韩在线观看免费完整版视频| 亚洲精品不卡视频| 亚洲男人天堂av| 亚洲AV无码码潮喷在线观看| 亚洲伊人久久成综合人影院| 精品国产精品久久一区免费式 | 午夜国产精品免费观看 | caoporm超免费公开视频| 久久亚洲欧美国产精品| 久久亚洲精品国产亚洲老地址| 久久夜色精品国产噜噜亚洲AV| 亚洲Av熟妇高潮30p| 亚洲AV人无码激艳猛片| 久久亚洲精品无码VA大香大香| 亚洲视频在线观看免费| 亚洲国产精品美女| 亚洲人成7777| 豆国产96在线|亚洲| 黄人成a动漫片免费网站| a免费毛片在线播放| 999久久久免费精品播放| 国产高清免费视频| 免费欧洲美女牲交视频| 亚洲真人无码永久在线| 亚洲欧洲日本国产| 黄人成a动漫片免费网站| 日本免费污片中国特一级| 免费视频专区一国产盗摄| 亚洲福利精品电影在线观看| 亚洲婷婷五月综合狠狠爱| 亚洲综合中文字幕无线码| 一区二区在线视频免费观看| 国产精品永久免费10000| 无码不卡亚洲成?人片| 亚洲人成毛片线播放| 51午夜精品免费视频| 日韩免费高清一级毛片在线| 亚洲邪恶天堂影院在线观看|