第一個div內的圖像應該與頂部第二個div中的列表水平對齊。但是,正如你所看到的,這個名單與上面有差距。請指導如何消除這種差距?如何將圖像與頂部列表進行水平對齊?
FIDDLE:https://jsfiddle.net/sryzdn/svg0716k/
HTML:
<div id="container">
<div id="div1"><img src="http://placehold.it/200x100"></div>
<div id="div2">
<ul>
<li>aaa</li>
<li>bbb</li>
<li>ccc</li>
</ul>
</div>
</div>
CSS:
#container {
width: 400px;
height: 400px;
background-color: red;
}
#div1 {
width: 200px;
height: 200px;
background-color: green;
float: left;
position: relative;
}
#div1 img {
position: absolute;
top: 0;
}
#div2 {
width: 200px;
height: 200px;
background-color: blue;
float: left;
positive: relative;
}
#div2 ul {
position: absolute;
top: 0;
}
#div2 li {
display: inline-block;
border: 1px solid black;
}
'ul {margin:0}'? –