dsh*_*dsh 30 css html5 google-chrome
我遇到了一个问题,我无法在Firefox和Chrome上使用相同的CSS来呈现相同的内容.它们不是一个包含24个值的垂直选择框,而是在Firefox中彼此相邻排列:
在Chrome中,它们显示为垂直多选框.
缩写3小时示例的完整代码:
<html>
<head>
<style type="text/css">
option { display: inline; }
</style>
</head>
<body>
<form>
<select id="aryHours[]" class="select_hours" size="1" multiple="multiple" name="aryHours[]">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在Chrome中,选项不会显示为内联.
任何解释为什么这个代码不起作用,有没有其他方法来实现相同的布局?
我不认为你应该(可以?)<option>
像这样内联元素.请尝试使用复选框.像这样的东西:
<!DOCTYPE html>
<html>
<head>
<title>Inline Options</title>
<style>
ul {
list-style:none;overflow:hidden;
}
ul li {
lit-style:none;
float:left;
position:relative;
}
ul li input[type="checkbox"] {
position:absolute;
top:0;
right:0;
bottom:0;
left:0;
width:100%;
height:100%;
opacity:0;
}
ul li input:checked + label {
background:blue;
}
</style>
</head>
<body>
<form action="#" method="get">
<ul>
<li>
<input type="checkbox" name="aryHours[]" id="checkbox1" />
<label for="checkbox1" class="">Option 1</label>
</li>
<li>
<input type="checkbox" name="aryHours[]" id="checkbox2" />
<label for="checkbox2" class="">Option 2</label>
</li>
<li>
<input type="checkbox" name="aryHours[]" id="checkbox3" />
<label for="checkbox3" class="">Option 3</label>
</li>
</ul>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3403 次 |
最近记录: |