帝王谷资源网 Design By www.wdxyy.com
原文:http://www.planabc.net/2008/07/24/legend_width/
我们在做表单的时候经常会使用到这样的结构:
<fieldset>
<legend>哪些浏览器legend标签设定的宽度有效</legend>
<input type="checkbox" value="ie6" name="width" id="ie6" checked="checked" /><label for="ie6">IE6</label>
<input type="checkbox" value="ie7" name="width" id="ie7"checked="checked" /><label for="firefox">IE7</label>
<input type="checkbox" value="firefox2" name="width" id="firefox2" /><label for="firefox2">Firefox2</label>
<input type="checkbox" value="firefox3" name="width" id="firefox3" /><label for="firefox3">Firefox3</label>
<input type="checkbox" value="opera" name="width" id="opera" checked="checked" /><label for="opera">Opera9.0 </label>
<input type="checkbox" value="safari" name="width" id="safari"checked="checked" /><label for="safari">Safari3.0 </label>
</fieldset> 当我们使用 CSS 给 legend 标签设定固定宽度时:
legend {
background:red;
width:500px;
}
在 IE6、IE7、Opera9.0 、Safari3.0 都正能常显示,而在 Firefox2 和 Firefox3 中宽度却失效。
在这里我们不去深究为什么,只探讨解决的方法:
我们可以通过在 legend 标签内添加一个标签,并给标签设定所需要的宽度,此宽度的单位不可为百分比(%):
HTML 修改为:
<fieldset>
<legend><span>哪些浏览器legend标签设定的宽度有效</span></legend>
<input type="checkbox" value="ie6" name="width" id="ie6" checked="checked" /><label for="ie6">IE6</label>
<input type="checkbox" value="ie7" name="width" id="ie7"checked="checked" /><label for="firefox">IE7</label>
<input type="checkbox" value="firefox2" name="width" id="firefox2" /><label for="firefox2">Firefox2</label>
<input type="checkbox" value="firefox3" name="width" id="firefox3" /><label for="firefox3">Firefox3</label>
<input type="checkbox" value="opera" name="width" id="opera" checked="checked" /><label for="opera">Opera9.0 </label>
<input type="checkbox" value="safari" name="width" id="safari"checked="checked" /><label for="safari">Safari3.0 </label>
</fieldset>
CSS 修改为:
legend span {
background:red;
width:500px;
display:block;
}
可参考:《how to set width of LEGEND tags in FF》
正淳 同时也提供了另外的一种解决方案,无需修改结构,仅修改样式即可:
legend {
background:red;
text-indent:-600px;
padding-left:600px;
/*IE下还原初始方式,只设定宽度*/
*width:600px;
*text-indent:0;
*padding-left:0;
}
题外话:CSS 的兼容其实并不难,多尝试多实践就可以解决,最重要的是自己要去动手,只有动手了才会有更多的收获,才会有更深的印象。
帝王谷资源网 Design By www.wdxyy.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
帝王谷资源网 Design By www.wdxyy.com
暂无评论...
更新日志
2024年10月07日
2024年10月07日
- 班得瑞原装进口《第八张新世纪专辑:琉璃湖畔》1CD[APE/CUE分轨][286.4MB]
- 魏如萱.2011-在哪里(EP)【添翼创越】【WAV+CUE】
- 群星.1981-新金曲奖·青年创作园地12合辑(喜玛拉雅复刻版)【歌林】【WAV+CUE】
- 麦洁文.1989-新曲与精丫新艺宝】【WAV+CUE】
- SNH48《薄荷糖 (Mint Candy)》[320K/MP3][33.72MB]
- SNH48《薄荷糖 (Mint Candy)》[FLAC/分轨][78.59MB]
- 刘美麟《同生》[320K/MP3][70.99MB]
- 群星.1994-宝丽金最流行3CD【宝丽金】【WAV+CUE】
- 群星.2024-聆听“某某”影视原声带【华纳】【FLAC分轨】
- 陈慧娴.1989-永远是你的朋友(2024环球MQA-UHQCD限量版)【环球】【WAV+CUE】
- 何洛洛.2024-别叫醒我(EP)【光羽】【FLAC分轨】
- 林忆莲.1996-爱莲说2CD【华纳】【WAV+CUE】
- 黄妃.2005-红【亚律】【WAV+CUE】
- 刘美麟《同生》[FLAC/分轨][161.95MB]
- 群星《前途海量 电影原声专辑》[320K/MP3][106.26MB]