我设法使用标准的HTML实现了期望的结果,但是当我开始修改布局以使用ASP.NET web控件时.我似乎无法得到同样的效果。我最初使用的CSS/HTML如下:
<html>
<head>
<style>
div.sqgrp1 {
position: absolute;
top: 123px;
height: 40px;
width: 40px;
border-style: solid;
border-width: 1px;
border-color: #178e62;
background-color: #6ec3a1;
padding-left:0px;
padding-top:0px;
padding-bottom:0px;
padding-right:0px;
border-radius:10px;
}
input[type="radio"] {
display: none;
}
input[type="radio"] + label span {
display: inline-block;
width: 40px;
height: 40px;
margin: 0px 0px 0px 0px;
vertical-align: middle;
cursor: pointer;
border-radius:10px;
background-color:red;
background-size:0px;
background:black;
opacity:0;
}
input[type="radio"]:checked + label span {
opacity: 0.6;
}
</style>
</head>
<body><form id="phq9" name="phq9" action="process.aspx" method="post" runat="server">
<div class="sqgrp1" style="left: 660px;">
<input type="radio"id="Q1A1" value="1" name="Q1" /><label for="Q1A1" ><span></span></label>
</div>
<div class="sqgrp1" style="left: 730px;">
<input type="radio"id="Q1A2" value="2" name="Q1" /><label for="Q1A2"><span></span></label>
</div>
<div class="sqgrp1" style="left: 800px;">
<input type="radio"id="Q1A3" value="3" name="Q1" /><label for="Q1A3"><span></span></label>
</div>
<div class="sqgrp1" style="left: 870px;">
<input type="radio"id="Q1A4" value="4" name="Q1" /><label for="Q1A4"><span></span></label>
</div>
</form>
</body>
</html>我尝试了几种在ASP.NET控件中实现相同效果的方法,但它们都没有起作用,所以我回到了常规的HTML控件。
发布于 2014-07-15 18:54:53
解决了我的问题。将所有控件设置为asp是可以的,但使标签asp:label导致CSS错误。通过将标签标记保留为普通html,CSS的工作方式完全相同,即使单选按钮为<asp:radiobutton runat="server">。
https://stackoverflow.com/questions/24740541
复制相似问题