如何将图像与顶部列表水平对齐?

时间:2016-05-02 15:13:36

标签: html css

第一个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;
}

3 个答案:

答案 0 :(得分:1)

删除maptree(f, (NODE(NODE(LEAF 1,LEAF 2),LEAF 3))); 媒体资源,并在top:0;

中添加margin-top: 0px
#div2 ul

答案 1 :(得分:0)

只需对$cmd = $client->getCommand('GetObject', [ 'Bucket' => $bucket, 'Key' => $file ]); $request = $client->createPresignedRequest($cmd, '+20 minutes'); $presignedUrl = (string)$request->getUri(); echo $presignedUrl; 使用margin-top: 0px即可。见new fiddle.

答案 2 :(得分:0)

请参阅此https://jsfiddle.net/0guuehj8/

评论postiton absolute和redefine padding

  #div2 ul {
  /*position: absolute;
   top: 0;*/
  margin:0px;
  -webkit-padding-start: 0px;
  padding: 0;
}