css如何自訂radio單選框樣式 ?(代碼實現)

來源:互聯網
上載者:User
本篇文章給大家帶來的內容是關於css如何自訂radio單選框樣式 ?(代碼實現),有一定的參考價值,有需要的朋友可以參考一下,希望對你有所協助。

html部分

<div class="radio">    <label>        <input name="feel" type="radio" value="love" />        <span class="pos">            <span class="radio_bg">                <span class="radio_on"></span>            </span>        </span>        <span>LOVE</span>    </label>    <label>        <input name="feel" type="radio" value="hate" />        <span class="pos">            <span class="radio_bg">                <span class="radio_on"></span>            </span>        </span>        <span>YOU ARE NICE</span>    </label></div>

css樣式部分

            .radio {                width: 260px;                height: 26px;                line-height: 26px;                margin: 200px auto;                background-color: #ddeef1;                font-size: 16px;                color: #495060;                text-align: center;            }                    label:first-child {                margin-right: 40px;            }            label input, .radio_on {              display: none;            }                        .pos {                display: inline;                vertical-align: middle;            }                    .radio_bg {              position: relative;              display: inline-block;              height: 14px;              width: 14px;              border: 1px solid #B3B4B8;              border-radius: 50%;            }                    label:hover .radio_bg, label input:checked + span.pos span.radio_bg {              border: 1px solid #27B28B;            }                    label input:checked + span.pos span.radio_bg .radio_on {              display: inline-block;              position: absolute;              top: 2px;              left: 2px;              width: 10px;              height: 10px;              border-radius: 50%;              background-color: #27B28B;            }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.