我已經寫了一個簡單的表單來測試CSS中的寬度。無論我爲寬度設置的值如何,邊框的寬度仍然相同。有人可以幫助我失去什麼嗎?CSS寬度:不在標籤中工作
<html lang="en-US">
<meta charset="UTF-8">
<head>
<style type="text/css">
label {
width: 10em;
border-color: brown;
border-width: .25em;
border-style: double;
margin-right: .5em;
}
</style>
<title>Trying CSS </title>
</head>
<body>
<form action="#">
<fieldset >
<label> Name </label>
<input type="text"/>
<label >Contact</label>
<input type="text" />
<label >Phone</label>
<input type="text" />
<button type="button">Submit </button>
</fieldset>
</form>
</body>
</html>
可能重複[我怎樣才能控制標籤標籤的寬度?](http://stackoverflow.co m/questions/2820586/how-can-i-control-width-of-label-tag) –
標籤標籤是'display:inline;'作爲默認值,所以寬度將無法工作。你可以用:display:inline-block;或者display:block;來使寬度工作。 'position:absolute | fixed','float:left | right'也可以使它工作,但只有在你知道你需要它時才使用它們。 – shuizhongyuemin
請問爲什麼浮動使它也起作用? – TimeToCodeTheRoad