Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 为什么单选按钮需要:name=";无线电“;用于CSS3识别_Html_Css_Radio Button - Fatal编程技术网

Html 为什么单选按钮需要:name=";无线电“;用于CSS3识别

Html 为什么单选按钮需要:name=";无线电“;用于CSS3识别,html,css,radio-button,Html,Css,Radio Button,尝试编辑两个单选按钮的外观,如果标记如下,则一切正常: <ul class="radioHorizontal"> <li class="spaceRight"> <input id="radioYes" type="radio" name="radios" checked> <label for="radioYes">Yes</label> </li> <li&g

尝试编辑两个单选按钮的外观,如果标记如下,则一切正常:

<ul class="radioHorizontal">
    <li class="spaceRight">
        <input id="radioYes" type="radio" name="radios" checked>
        <label for="radioYes">Yes</label>
    </li>
    <li>
        <input id="radioNo" type="radio" name="radios">
        <label for="radioNo">No</label>
    </li>
</ul>

我使用name=“radios”没有问题,除非某些不可预见的、奇怪的特殊情况禁止它,我只是好奇为什么CSS3需要这样做。

它根本不会影响CSS,但需要名称来对它们进行分组。一个组中只能选择一个单选按钮,其他单选按钮将自动取消选择。如果你不给他们一个名字,他们每个人都在他们自己的组中。

这根本不会影响CSS,但是对他们进行分组需要名字。一个组中只能选择一个单选按钮,其他单选按钮将自动取消选择。如果你不给他们一个名字,他们每个人都在他们自己的组中。

不需要特定的名字,但是如果你想让他们彼此链接,他们需要有相同的名字属性。CSS与此无关,这是用HTML单选按钮分组的方式。@kalley谢谢,代表我这么愚蠢的忽略。它不需要那个特定的名称,但如果你想让它们彼此链接,它们需要具有相同的名称属性。CSS与此无关,这是用HTML单选按钮分组的方式。@kalley谢谢你,代表我这么愚蠢的忽略。代表我这么愚蠢的忽略。我一有机会就接受这个答案。这是多么愚蠢的疏忽啊。我会尽快接受这个答案。
My CSS3 is as follows:

    input[ type = radio ]
{
    display:none; 
}

input[ type = radio ] + label
{
    padding: 4px 12px;
    background-color: rgba( 40, 40, 40, 1 );

    border: 2px solid rgb( 30, 30, 30 );
    box-shadow: 0px 1px 0px rgba( 125, 125, 125, 0.75 );
}

input[ type = radio ]:checked + label
{ 
    background-image: none;
    background-color: rgba( 255, 255, 255, 0.4 );
}