<small id="egjlb"></small>
<i id="egjlb"></i><small id="egjlb"><div id="egjlb"><cite id="egjlb"></cite></div></small>
      1. <span id="egjlb"><code id="egjlb"><p id="egjlb"></p></code></span>
      2. 技術頻道導航
        HTML/CSS
        .NET技術
        IIS技術
        PHP技術
        Js/JQuery
        Photoshop
        Fireworks
        服務器技術
        操作系統
        網站運營

        贊助商

        分類目錄

        贊助商

        最新文章

        搜索

        一組精致好看的CSS表單樣式:checkbox、radio、text等

        作者:admin    時間:2022-12-13 18:56:34    瀏覽:

        一個精致漂亮的網頁表單,可讓你的網頁立即變得上了檔次,本文將給你介紹一個精美的CSS表單樣式,并提供源文件下載,真正做到即拿即用。

         一組精致好看的CSS表單樣式

        demodownload

        HTML代碼

        <fieldset>
          <legend>一些關于你的資料</legend>
          <label for="fullname">姓名:</label>
          <input type="text" id="fullname" />
          <p>性別:</p>
          <p>
            <input type="radio" value="male" id="male" name="gender" />
            <label for="male">男</label>
          </p>
          <p>
            <input type="radio" value="Female" id="female" name="gender" />
            <label for="female">女</label>
          </p>
          <p>你喜歡的語言:</p>
          <p>
            <input type="checkbox" value="CSS3" id="css3" />
            <label for="css3">CSS3</label>
          </p>
          <p>
            <input type="checkbox" value="HTML5" id="html5" />
            <label for="html5">HTML5</label>
          </p>
          <p>
            <input type="checkbox" value="JavaScript" id="javascript" />
            <label for="javascript">JavaScript</label>
          </p>
          <p>
            <input type="checkbox" value="Other" id="other" />
            <label for="other">Other</label>
          </p>
        </fieldset>

        沒有什么特別之處,使用的是原始控件(checkbox、radio、text)常規的代碼。input加上label控件組合起來排版布局。

        CSS代碼

        因為代碼分別為checkbox、radio、text等控件專屬,所以總共代碼有點多,CSS樣式文件包含在下載包里。

        /* 選中(Checked)樣式 */
        p:not(#foo) > input[type=radio]:checked + label  { background-position: 0 -241px; }
        p:not(#foo) > input[type=checkbox]:checked + label  { background-position: 0 -81px; }
        p:not(#foo) > input[type=checkbox]:hover:checked + label,
        p:not(#foo) > input[type=checkbox]:focus:checked + label,
        p:not(#foo) > input[type=checkbox]:checked + label:hover,
        p:not(#foo) > input[type=checkbox]:focus:checked + label  { background-position: 0 -101px; }
        p:not(#foo) > input[type=radio]:hover:checked + label,
        p:not(#foo) > input[type=radio]:focus:checked + label,
        p:not(#foo) > input[type=radio]:checked + label:hover,
        p:not(#foo) > input[type=radio]:focus:checked + label  { background-position: 0 -261px; }

        /* 鼠標懸停(hover)和聚焦(focus)樣式 */
        p:not(#foo) > input[type=checkbox]:hover + label,
        p:not(#foo) > input[type=checkbox]:focus + label,
        p:not(#foo) > input[type=checkbox] + label:hover  { background-position: 0 -21px; }
        p:not(#foo) > input[type=radio]:hover + label,
        p:not(#foo) > input[type=radio]:focus + label,
        p:not(#foo) > input[type=radio] + label:hover { background-position: 0 -181px; }

        /* 活動(active)樣式 */
        p:not(#foo) > input[type=checkbox]:active + label,
        p:not(#foo) > input[type=checkbox] + label:hover:active { background-position: 0 -41px; }
        p:not(#foo) > input[type=radio]:active + label,
        p:not(#foo) > input[type=radio] + label:hover:active { background-position: 0 -201px; }
        p:not(#foo) > input[type=checkbox]:active:checked + label,
        p:not(#foo) > input[type=checkbox]:checked + label:hover:active { background-position: 0 -121px; }
        p:not(#foo) > input[type=radio]:active:checked + label,
        p:not(#foo) > input[type=radio]:checked + label:hover:active { background-position: 0 -281px; }

        /* 禁用(disabled)樣式 */
        p:not(#foo) > input[type=checkbox]:disabled + label,
        p:not(#foo) > input[type=checkbox]:hover:disabled + label,
        p:not(#foo) > input[type=checkbox]:focus:disabled + label,
        p:not(#foo) > input[type=checkbox]:disabled + label:hover,
        p:not(#foo) > input[type=checkbox]:disabled + label:hover:active { background-position: 0 -61px; }
        p:not(#foo) > input[type=radio]:disabled + label,
        p:not(#foo) > input[type=radio]:hover:disabled + label,
        p:not(#foo) > input[type=radio]:focus:disabled + label,
        p:not(#foo) > input[type=radio]:disabled + label:hover,
        p:not(#foo) > input[type=radio]:disabled + label:hover:active { background-position: 0 -221px; }
        p:not(#foo) > input[type=checkbox]:disabled:checked + label,
        p:not(#foo) > input[type=checkbox]:hover:disabled:checked + label,
        p:not(#foo) > input[type=checkbox]:focus:disabled:checked + label,
        p:not(#foo) > input[type=checkbox]:disabled:checked + label:hover,
        p:not(#foo) > input[type=checkbox]:disabled:checked + label:hover:active { background-position: 0 -141px; }
        p:not(#foo) > input[type=radio]:disabled:checked + label,
        p:not(#foo) > input[type=radio]:hover:disabled:checked + label,
        p:not(#foo) > input[type=radio]:focus:disabled:checked + label,
        p:not(#foo) > input[type=radio]:disabled:checked + label:hover,
        p:not(#foo) > input[type=radio]:disabled:checked + label:hover:active { background-position: 0 -301px; }

        上面為部分代碼,完整代碼在下載包文件里。

        使用注意問題

        CSS用到一個圖片,使用時應注意路徑正確。

        p:not(#foo) > input + label
        {
          background: url(gr_custom-inputs.png) 0 -1px no-repeat;
          height: 16px;
        }

        支持瀏覽器

        • Firefox 1.5+
        • Opera 9.6+
        • Safari 3.2+*
        • iPhone/iPod Safari**
        • Chrome 4+
        • IE9+

        相關文章

        標簽: css  表單  登錄表單  注冊表單  
        x
        • 站長推薦
        亚洲成A人片在线观看无码专区_2021色精品极品在线观看视频_亚洲午夜精品A片一区二区无码l_992tv在线观看视频国产