CSS執行個體(八):不用圖片實現寬度、高度自定的圓角矩形

來源:互聯網
上載者:User

根據google的analytics介面分析整理,個人覺得不錯。雖然元素多了點兒、看起來複雜了點兒、樣子不那麼非常美觀,但是可以隨意設定圓角矩形的寬度及高度,很靈活。
  不知為什麼google用了b元素,有點奇怪。

  頁面源碼:Html代碼  

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
  2. <html xmlns="http://www.w3.org/1999/xhtml">   
  3. <head>   
  4.     <meta http-equiv="Content-Type" content="text/html; charset=GB2312"/>   
  5. <title></title>  
  6. <style type="text/css">  
  7.     html,body{  
  8.         font-size:12px;  
  9.     }  
  10.     .round_border,.round_border b{  
  11.         display:block;  
  12.         text-align:center;  
  13.     }  
  14.     .round_border_layer3,.round_border_layer2,.round_border_layer1,  
  15.     .round_border_content{  
  16.         border:1px solid #c4c4c4;  
  17.         border-width:0 1px 0 1px;  
  18.         height:1px;  
  19.         overflow:hidden;  
  20.     }  
  21.     .round_border_layer3{  
  22.         margin:0 3px;  
  23.         background:#c4c4c4;  
  24.     }  
  25.     .round_border_layer2{  
  26.         margin:0 2px;  
  27.     }  
  28.     .round_border_layer1{  
  29.         margin:0 1px;  
  30.     }  
  31.     .round_border_content{  
  32.         height:300px;  
  33.         padding:3px 6px;  
  34.     }  
  35.     /*only for better appearance, not necessary, http://wallimn.iteye.com*/  
  36.     .round_border_layer2,.round_border_layer1{  
  37.         border-color:#d3d4d5;  
  38.     }  
  39.     /*******************control bar**********************/  
  40.     .controlbar_border_layer3,.controlbar_border_layer2,.controlbar_border_layer1,  
  41.     .controlbar_border_content{  
  42.         background:#e9e9e9;  
  43.         height:1px;  
  44.         overflow:hidden;  
  45.     }  
  46.     .controlbar_border_layer3{  
  47.         margin:0 3px;  
  48.     }  
  49.     .controlbar_border_layer2{  
  50.         margin:0 2px;  
  51.     }  
  52.     .controlbar_border_layer1{  
  53.         margin:0 1px;  
  54.     }  
  55.     .controlbar_border_content{  
  56.         height:20px;  
  57.         padding:0 1em;  
  58.         line-height:20px;  
  59.         vertical-align:middle;  
  60.     }  
  61.     /*only for better appearance, not necessary, http://wallimn.iteye.com*/  
  62.     .controlbar_border_layer1,..controlbar_border_layer2{  
  63.         border-color:#f2f2f2;  
  64.     }  
  65. </style>  
  66. </head>  
  67. <body>  
  68.     <div style="width:260px;">  
  69.         <b class="round_border">  
  70.             <b class="round_border_layer3"></b>  
  71.             <b class="round_border_layer2"></b>  
  72.             <b class="round_border_layer1"></b>  
  73.         </b>  
  74.         <div class="round_border_content">  
  75.             <b class="round_border">  
  76.                 <b class="controlbar_border_layer3"></b>  
  77.                 <b class="controlbar_border_layer2"></b>  
  78.                 <b class="controlbar_border_layer1"></b>  
  79.             </b>  
  80.             <div class="controlbar_border_content">  
  81.                 隔壁CSS
  82.             </div>  
  83.             <b class="round_border">  
  84.                 <b class="controlbar_border_layer1"></b>  
  85.                 <b class="controlbar_border_layer2"></b>  
  86.                 <b class="controlbar_border_layer3"></b>  
  87.             </b>  
  88.         </div>  
  89.         <b class="round_border">  
  90.             <b class="round_border_layer1"></b>  
  91.             <b class="round_border_layer2"></b>  
  92.             <b class="round_border_layer3"></b>  
  93.         </b>  
  94.     </div>  
  95. </body>  
  96. </html>  

  效果(編輯調試瀏覽器IE7):

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.