-2
爲什麼不是第一個元素與容器中的其他元素內聯?我無法弄清楚爲什麼這樣做。該代碼段可以正常工作,但是當我在網頁上運行代碼時不會發生這種情況。什麼可能導致一個元素這樣做?容器中的元素不是嵌套
.search {
background-color: #2a7a2e;
border: none;
color: white;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
margin-top: 4px;
cursor: pointer;
width: 60px;
height: 20px;
}
.searchtag {
margin: 4px;
width: 100px;
height: 20px;
font-size: 12px;
}
cloudcontainer {
width: 940px;
border-style: solid;
border-width: 5px;
float: left;
}
cloudcontainer:after {
content: "";
display: table;
clear: both;
}
.tagcloud {
background-color: #2a7a2e;
border: none;
color: white;
text-align: center;
text-decoration: none;
font-size: 12px;
margin: 2px 2px 2px 2px;
cursor: pointer;
float: left;
width: auto;
height: 20px;
border-style: solid;
border-width: 1px;
}
<form id="search">
<input class="searchtag" type="text" id="search" name="search">
<button class="search" type="submit" formaction="go.php"
method="GET">Search</button>
</form>
<cloudcontainer>
<form id="search"><button class="tagcloud" type="submit" formaction="go.php" method="GET">zzz</button>
<input type="hidden" id="search" name="search" value="zzz"></form>
<form id="search"><button class="tagcloud" type="submit" formaction="go.php" method="GET">aa</button>
<input type="hidden" id="search" name="search" value="aa"></form>
<form id="search"><button class="tagcloud" type="submit" formaction="go.php" method="GET">aaa</button>
<input type="hidden" id="search" name="search" value="aaa"></form>
</cloudcontainer>
您添加的代碼片段似乎是內嵌的 – omer
您發佈的代碼段工作正常。除非我們能夠重現問題,否則將很難診斷。請花時間包含所有相關代碼 –
我知道我應該粘貼所有代碼。我已經添加了所有相關的代碼,我不明白爲什麼結果是不同的。 – MikeSkril