DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> CSS入門知識 >> DIV十CSS布局 >> 布局實例
下拉選單 select 樣式設定:相容 IE6/7/8 與 Firefox
編輯:布局實例     

下拉選單 select 的樣式向來是跨瀏覽器的一大痛點,不同瀏覽器對它的解讀差異極大。本文示範如何設定樣式,讓它在 IE6/IE7/IE8 與 Firefox 上都有一致的外觀。

關鍵在於針對 IE 的私有 hack

.select_border{
  width:59px;
  height:29px;
  *background:#fff;
  background:#fff;
  *border:1px solid #09f;
  *padding:4px;
  *height:20px;
}
.container{
  *border:0;
  *position:relative;
  *height:18px;
  *overflow:hidden;
}
.select{
  border:1px solid #09f;
  padding:4px 3px;
  font-size:12px;
  height:30px;
  width:60px;
  *width:52px;
  margin:-1px;
}
.select_border,.container { *width:50px; }

結構

把 select 包進 .container,再包進 .select_border。帶星號 * 的屬性只對 IE 生效,藉此微調各版本 IE 的寬高與邊框,讓最終外觀在各大瀏覽器間保持一致。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved