Home > Web Front-end > CSS Tutorial > Create radio button using css style

Create radio button using css style

王林
Release: 2020-05-31 16:33:34
forward
3811 people have browsed it

Create radio button using css style

Let’s take a look at the specific implementation code directly:

(If you want to learn css, then here is the css video tutorial recommended to you)

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./reset.css">
    <style>
        .radio-diy .radiocircle {
            width: 12px;
            height: 12px;
            border: 1px solid #999;
            border-radius: 50%;
            cursor: pointer;
            display: inline-block;
        }
        
        .radio-diy input:checked+span {
            border: 1px solid#008c8c;
        }

        .radio-diy input:checked~span {
            color: #008c8c;
        }

        .radio-diy input:checked+span.radiocircle::after {
            content: "";
            display: block;
            width: 6px;
            height: 6px;
            background: #008c8c;
            border-radius: 50%;
            cursor: pointer;
            margin-left: 3px;
            margin-top: 3px;
        }



        input[type="radio"] {
            display: none;
        }
    </style>
</head>

<body>
    请选择性别:
    <label>
        <input type="radio" name="gender" value="male">
        <span></span>
        <span>男</span>
    </label>
    <label>
        <input type="radio" name="gender" value="female">
        <span></span>
        <span>女</span>
    </label>
</body>

</html>

radio.css
Copy after login

Effect display:

Create radio button using css style

Recommended tutorial: css quick start

The above is the detailed content of Create radio button using css style. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template