DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> CSS入門知識 >> 關於CSS
13 組常用表單 CSS 樣式:按鈕、輸入框與下拉選單
編輯:關於CSS     

CSS 的學習终究要靠動手實作與思考,但平時注意收集與整理素材同樣重要,實際開發時往往能事半功倍。以下整理十三組針對按鈕、文字框與表單的樣式,可直接取用再依專案調整。

一、基本按鈕

.buttoncss {
  font-family: "tahoma", "新細明體";
  font-size: 9pt;
  color: #006699;
  border: 1px #93bee2 solid;
  background: #e8f4ff url(../images/bluebuttonbg.gif);
  cursor: pointer;
  width: 60px;
  height: 22px;
}

二、藍色按鈕

.bluebuttoncss {
  font-family: "tahoma", "新細明體";
  font-size: 9pt;
  color: #003366;
  border: 1px #93bee2 solid;
  background: #fff url(../images/blue_button_bg.gif);
  cursor: pointer;
}

三、紅色按鈕

.redbuttoncss {
  font-family: "tahoma", "新細明體";
  font-size: 9pt;
  color: #0066cc;
  border: 1px #93bee2 solid;
  background: #fff url(../images/redbuttonbg.gif);
  cursor: pointer;
}

四、綠色按鈕

.greenbuttoncss {
  font-family: "tahoma", "新細明體";
  font-size: 9pt;
  color: #0066cc;
  border: 1px #93bee2 solid;
  background: #fff url(../images/greenbuttonbg.gif);
  cursor: pointer;
}

五、圖像按鈕

.imagebutton { cursor: pointer; }

六、頁面正文與表格文字

body {
  font-size: 9pt;
  color: #003366;
}
td, th { font-size: 12px; }

舊作中常見的 scrollbar-* 系列屬性(scrollbar-face-color、scrollbar-arrow-color 等)僅 IE 支援,已不建議使用;現在若要自訂捲軸樣式,請改用 ::-webkit-scrollbar 或標準的 scrollbar-color。

七、下拉選單

select {
  font-size: 12px;
  color: #003366;
  border: 1px solid #b7b7b7;
  background-color: #f4f4f4;
}

八、單行文字輸入框

.editbox {
  background: #fff;
  border: 1px solid #b7b7b7;
  color: #003366;
  cursor: text;
  font-family: arial, sans-serif;
  font-size: 9pt;
  height: 18px;
  padding: 1px 4px;
}

九、多行文字輸入框

.multieditbox {
  background: #f8f8f8;
  border: 1px solid #b7b7b7;
  color: #000;
  cursor: text;
  font-family: arial, sans-serif;
  font-size: 9pt;
  padding: 4px;
}

十、陰影風格容器

.shadow {
  position: absolute;
  z-index: 1000;
  top: 0;
  left: 0;
  background-color: #ffcc00;
  filter: progid:DXImageTransform.Microsoft.dropshadow(
    color=#404040, offx=2, offy=2, positive=true);
}

其中的 filter 屬性是 IE 私有寫法,現代瀏覽器請改用 box-shadow: 2px 2px 6px rgba(0,0,0,.4);。

十一、只有一條底線的輸入框

.logintxt {
  border: none;
  border-bottom: 1px solid #c0c0c0;
  background-color: #fff;
  font-size: 9pt;
}

十二、完全沒有邊框的輸入框

.noneinput {
  text-align: center;
  width: 99%;
  height: 99%;
  border: none;
  background-color: #f6f6f6;
}

十三、瀏覽器相容的小提醒

早期撰寫表單樣式時,cursor: hand 只有 IE 認得,其他瀏覽器請一律寫 cursor: pointer;另外,<input> 與 <textarea> 的字型不會自動繼承,記得明確指定 font-family,否則在部分環境下會落到系統預設字型。最後別忘了 :focus 狀態——鍵盤使用者需要清楚看到目前游標在哪個欄位,這是無障礙的基本要求:

input:focus, textarea:focus, select:focus {
  border-color: #3b7ddd;
  outline: 2px solid #3b7ddd;
}
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved