小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

CSS BUG

 歪SIR 2011-07-24
大部分BUG是人為的

CSS 編寫不規(guī)范,語(yǔ)法錯(cuò)誤可以用 W3C CSS 檢驗(yàn)器
http://jigsaw./css-validator/

選擇器特殊性問(wèn)題,可以用FireBug解決


IMG與 line-height沖突


Html代碼  收藏代碼
  1. <style type="text/css">  
  2.    div.v-align {  
  3.      border: 1px solid red;  
  4.      height: 200px;  
  5.      line-height: 200px;  
  6.      float: left;  
  7.    }  
  8.    div.v-align img {  
  9.      padding-top: 90px; /* fix bug */  
  10.      vertical-align: middle;  
  11.    }  
  12.  </style>  
  13.   
  14.  <div class="v-align">  
  15.    正常  
  16.  </div>  
  17.  <div class="v-align">  
  18.    <img src="./accept.png" />  
  19.  </div>  


例子1:
Html代碼  收藏代碼
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www./1999/xhtml" xml:lang="en">  
  3. <head>  
  4. <title>AgiCRM</title>  
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />  
  6. <meta name="demo" content="Demo" />  
  7. <meta name="demo" content="demo" />  
  8.   <style type="text/css">  
  9.     div.v-align {  
  10.       border: 1px solid red;  
  11.       line-height: 40px;  
  12.       float: left;  
  13.       font-size: 11px;  
  14.       height: 40px;  
  15.     }  
  16.     div.v-align img.only-img {  
  17.       float:left;  
  18.     }  
  19.     div.v-align.has-img {  
  20.       padding-top: 10px;  
  21.       height: 30px;  
  22.     }  
  23.   
  24.     div.v-align.has-img-and-text img.has-text {  
  25.       vertical-align: -4px !important;  
  26.       vertical-align: middle;  
  27.       margin-top: -3px !important;  
  28.       margin-top: 0px;  
  29.     }  
  30.     div.v-align.has-img-and-text {  
  31.       padding-top: 0px !important;  
  32.       padding-top: 10px;  
  33.       height: 40px !important;  
  34.       height: 30px;  
  35.     }  
  36.   </style>  
  37. <!--[if IE]>  
  38.   
  39. <![endif]-->  
  40. </head>  
  41. <body>  
  42.   <div class="v-align">  
  43.     正常  
  44.   </div>  
  45.   <div class="v-align has-img">  
  46.     <img src="./accept.png" class="only-img" />  
  47.   </div>  
  48.   <div class="v-align has-img-and-text">  
  49.     <img src="./accept.png" align="absmiddle" class="has-text" />有圖片有字  
  50.   </div>  
  51. </body>  
  52. </html>  


絕對(duì)定位 right
Html代碼  收藏代碼
  1. <style type="text/css">  
  2.    div.box {  
  3.      border: 1px solid red;  
  4.      background-color: black;  
  5.      height: 200px;  
  6.      position: relative;  
  7.    }  
  8.    div.box img {  
  9.      position: absolute;  
  10.      right: 0px !important;  
  11.      right: -1px; /* fix IE 6 */  
  12.      border: 1px solid white;  
  13.    }  
  14.  </style>  
  15.   
  16.  <div class="box">  
  17.    <img src="./accept.png" />  
  18.  </div  


例子2:
Html代碼  收藏代碼
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www./1999/xhtml" xml:lang="en">  
  3. <head>  
  4. <title>AgiCRM</title>  
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />  
  6. <meta name="demo" content="Demo" />  
  7. <meta name="demo" content="demo" />  
  8.   <style type="text/css">  
  9.     div.box {  
  10.       border: 1px solid red;  
  11.       background-color: black;  
  12.       height: 200px;  
  13.       position: relative;  
  14.       padding:0px;  
  15.     }  
  16.     div.box img {  
  17.       position: absolute;  
  18.       right: 0px !important;  
  19.       right: -1px; /* fix IE 6 */  
  20.       border: 1px solid white;  
  21.     }  
  22.   </style>  
  23. <!--[if IE]>  
  24.   
  25. <![endif]-->  
  26. </head>  
  27. <body>  
  28.   <div class="box">  
  29.     <img src="./accept.png" />  
  30.   </div>  
  31. </body>  
  32. </html>  


雙倍空白邊浮動(dòng)BUG(IE6-)

Html代碼  收藏代碼
  1. <style type="text/css">  
  2.     div.box {  
  3.       border: 1px solid red;  
  4.       background-color: #ccc;  
  5.       height: 200px;  
  6.       width: 400px  
  7.     }  
  8.     div.box .item {  
  9.       border: 1px solid blue;  
  10.       float: left;  
  11.       margin-left: 20px;  
  12.       display: inline; /* Fix for IE 6 */  
  13.     }  
  14. </style>  
  15.   
  16. <div class="box">  
  17.     <div class="item">  
  18.       Content  
  19.     </div>  
  20.   </div>  


例子3:
Html代碼  收藏代碼
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www./1999/xhtml" xml:lang="en">  
  3. <head>  
  4. <title>AgiCRM</title>  
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />  
  6. <meta name="demo" content="Demo" />  
  7. <meta name="demo" content="demo" />  
  8.   <style type="text/css">  
  9.     div.box {  
  10.       border: 1px solid red;  
  11.       background-color: #ccc;  
  12.       height: 200px;  
  13.       width: 400px  
  14.     }  
  15.     div.box .item {  
  16.       border: 1px solid blue;  
  17.       float: left;  
  18.       margin-left: 20px;  
  19.       /*display: inline; /* Fix for IE 6 */*/  
  20.     }  
  21.   </style>  
  22. <!--[if IE]>  
  23.   
  24. <![endif]-->  
  25. </head>  
  26. <body>  
  27.   <div class="box">  
  28.     <div class="item">  
  29.       Content  
  30.     </div>  
  31.   </div>  
  32. </body>  
  33. </html>  


莫名其妙的 3px BUG(IE6-)
Html代碼  收藏代碼
  1. <style type="text/css">  
  2.     * {  
  3.       margin: 0;  
  4.       padding: 0;  
  5.     }  
  6.     div.box {  
  7.       border: 1px solid #ccc;  
  8.       margin: 0;  
  9.       padding: 0px;  
  10.       float: left;  
  11.       width: 100px;  
  12.       height: 50px;  
  13.       margin-right: 0px !important;  
  14.       margin-right: -3px;  
  15.     }  
  16.   </style>  
  17.   
  18.   <div class="box">  
  19.   </div>  
  20.   <p>  
  21.   莫名其妙的3px  
  22.   </p>  


例子4:

Html代碼  收藏代碼
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www./1999/xhtml" xml:lang="en">  
  3. <head>  
  4. <title>AgiCRM</title>  
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />  
  6. <meta name="demo" content="Demo" />  
  7. <meta name="demo" content="demo" />  
  8.   <style type="text/css">  
  9.     * {  
  10.       margin: 0;  
  11.       padding: 0;  
  12.     }  
  13.     div.box {  
  14.       border: 1px solid #ccc;  
  15.       margin: 0;  
  16.       padding: 0px;  
  17.       float: left;  
  18.       width: 100px;  
  19.       height: 50px;  
  20.       margin-right: 0px !important;  
  21.       margin-right: -3px;  
  22.     }  
  23.   </style>  
  24. <!--[if IE]>  
  25.   
  26. <![endif]-->  
  27. </head>  
  28. <body>  
  29.   <div class="box">  
  30.   </div>  
  31.   <p>  
  32.   莫名其妙的3px  
  33.   </p>  
  34. </body>  
  35. </html>  


當(dāng)出現(xiàn)BUG時(shí)用border標(biāo)出容器

Html代碼  收藏代碼
  1. <style type=“text/css”>  
  2.     div.parent-box {  
  3.          border: 1px sold red; /* Use border and different color*/  
  4.    }  
  5.     div.child-box {  
  6.          border: 1px sold green; /* Use border and different color*/  
  7.    }  
  8. </style>  
  9. <div class=“parent-box”>  
  10.   <div class=“child-box”></div>  
  11. </div>  


修復(fù)問(wèn)題,而不是修復(fù)癥狀
知道問(wèn)題根源后,再根據(jù)這個(gè)根源去修復(fù),
否則會(huì)是治標(biāo)不治本
像本課程 IMG 與 line-height 沖突還只是治標(biāo),
還不知道其真正原因


    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約