Fieldset,Width,Label,Internet Explorer错误

时间:2012-12-11 08:55:43

标签: css forms internet-explorer-9 size internet-explorer-10

在此示例中仅限Internet Explorer 9或10 http://jsfiddle.net/QQxgg/ 如果我放置主场集的宽度,例如655px,则文本标签大于正常值。

在Firefox和Chrome中,标签尺寸为自动宽度,因此行为正常。 可以在Internet Explorer中指定字段集的宽度和标签自动宽度吗? 感谢。

ie9,10

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style>
fieldset {
width: 655px;
}

fieldset {
    display: table;
}
fieldset p {
    display: table-row;
}
fieldset input, 
fieldset select, 
fieldset label {
    display: table-cell;
    margin: 3px;    
}
fieldset label {
    text-align: right;
}

</style>
</head>
<body>

<fieldset>          
<p><label>First Name: </label><input type="text" /></p>
<p><label>Second Name: </label><input type="text" /></p>
<p><label>Country: </label><select><option>Choose</option></select></p>
<p><label>Age: </label><select><option>Choose</option></select></p>
</fieldset> 

</body>
</html>

2 个答案:

答案 0 :(得分:0)

你想要这样的东西吗?

ie image for field set

这是代码,

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style>
fieldset {
width: 500px;
}
fieldset {
    display: inline-block;
}
fieldset input, 
fieldset select, 
fieldset label {
    display: table-cell;
    margin: 3px;    
}
fieldset label {
    text-align: right;
}
</style>
</head>
<body>
<fieldset>          
<label>First Name: </label><input type="text" /><br>
<label>Second Name: </label><input type="text" /><br>
<label>Country: </label><select><option>Choose</option></select><br>
<label>Age: </label><select><option>Choose</option></select>
</fieldset> 
</body>
</html>

答案 1 :(得分:0)

我的问题已解决,强制标签为1px并设置white-space:nowrap; 示例:http://jsfiddle.net/DpGcW/

fieldset label {
text-align: right;
width: 1px;
white-space:nowrap;
}