1
1

More than 5 years have passed since last update.

ラジオボタンのデザインをCSS3の擬似要素で変更する

Last updated at Posted at 2013-12-10
input[type="radio"] {
    -webkit-appearance: none;
    position: relative;
    margin-right: 5px;
    border-radius: 30px;
    border: 2px solid #736b68;
    -webkit-box-sizing: border-box;
    width: 30px;
    height: 30px;
    background: -webkit-gradient(
        linear,
        left top,
        left bottom,
        from(#fdfdfd),
        to(#d1d1d1)
    );
    vertical-align: middle;
}
input[type="radio"]:disabled {
    border: 2px solid #EEE;
}
/* チェック時は背景色を変更 */
input[type="radio"]:checked {
    background: -webkit-gradient(
        linear,
        left top,
        left bottom,
        from(#aaa),
        to(#ccc)
    );
}

/* チェックの印を:before疑似要素を使って作成 */
input[type="radio"]:checked:before {
    position: absolute;
    left: 50%;
    top: 50%;
    display: block;
    margin: -9px 0 0 -9px;
    -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
    content: "";
    border-radius: 50px;
    width: 18px;
    height: 18px;
    background: -webkit-gradient(
        linear,
        left top,
        left bottom,
        from(#43c915),
        to(#43c915)
    );
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1