gpt4 book ai didi

php - 单选按钮代码在 Firefox 中正常,但在其他浏览器中不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 03:58:01 25 4
gpt4 key购买 nike

给定的代码适用于 firefox,但不适用于任何其他浏览器。

我是不是用单选按钮做错了

我只想要 3 个按钮,但当用户单击突出显示的选项时,我已经设置了样式

这是我的代码:

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title></title>
</head>
<style>
.radio > input[type=radio]{
display:none;
visibility:hidden;
}
input[type=radio] + label{
cursor:pointer;
}
input[type=radio]:checked + label{
background-color:green;
}

.but1{
background-color:#009;
color:#FFF;
border:none;
border-radius:15px;
width:200px;
height:50px;
font-size:18px;
font-weight:bold;
border-radius:15px;
text-align:center;
padding:8px;
font-family:Verdana, Geneva, sans-serif;
float:left;
margin-left:10px;
}
</style>
</head>

<body>
<form action="Untitled2.php" method="post">
<label class="radio" for="fb1">
<input id="fb1" type="radio" name="time" value="all day" checked />
<label class="but1">Available<br>All day</label>
</label>

<label class="radio" for="fb2">
<input id="fb2" type="radio" name="time" value="between 8-12"/>
<label class="but1">Between<br>8am - 12am</label>
</label>

<label class="radio" for="fb3">
<input id="fb3" type="radio" name="time" value="between 12-4" />
<label class="but1">Between<br>12pm - 4pm</label>
</label>

<input name="submit" type="submit" />
</form>
</body>
</html>

我该怎么做?

最佳答案

你的外部 label 是多余的,你可以这样做:

<input id="fb1" type="radio" name="time" value="all day" checked />
<label class="but1" for="fb1">Available<br>All day</label>

<input id="fb2" type="radio" name="time" value="between 8-12"/>
<label class="but1" for="fb2">Between<br>8am - 12am</label>

<input id="fb3" type="radio" name="time" value="between 12-4" />
<label class="but1" for="fb3">Between<br>12pm - 4pm</label>

此外,用于隐藏单选按钮的 css 是错误的,应该是:

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

Fiddle

关于php - 单选按钮代码在 Firefox 中正常,但在其他浏览器中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22496346/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com