图像下方的文字位于其他图像的顶部?

时间:2016-02-04 10:06:17

标签: html css image tabs

所以我正在制作这个小游戏,你需要在图像下拖动文字。 我需要在需要拖动文本的图像下做一些小标签。

我想在图像周围放置一个div,并在div中为div选择另一个div,在css中我将标签设置为25px的高度。但是25px,不会在同一个div中的图像下面,它高于该行中的其他图像..

这就是我看到的,http://prntscr.com/9yv7m8 红色空间是标签,需要在图片下面..

我该如何正确解决这个问题?

这是我的代码, CSS

body, html {
  margin-left: 10%;
  margin-right: 10%;
  padding: 0px;
  height: 100%;
  font-family: georgia, "Comic Sans MS";
  background-color: #f0f0f0;
}

header {
  height: 5%;
  border-bottom: thick solid grey;
}

footer {
    height: 5%;
    border-top: thick solid grey;
}
.points {
    float: right;
}
.container {
  width: 100%;
  height: 90%;
}

.plaatje {
  width: 100px;
  height: 100px;
}
.plaatje2 {
  float: left;
  width: 25%;
}
.igen {
  font-size: 25px;
  font-weight: bold;
}
.sprint {
  float: right;

}
.copyright {
  position: relative;
  bottom: 20px;
  left: 65px;
  font-size: 10px;
}

.img {
  width: 25%;
  height: 25%;
  float: left;
}
.img2 {
  width: 25%;
  height: 25%;
  float: left;
}
.answer {
  height: 25px;
}
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>Words</title>

    <link rel="stylesheet" href="css/style.css" media="screen" title="no title" charset="utf-8">
    <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">

  <script>
  </script>

</head>
<body>

<header>
 <span class="fa fa-refresh" style="font-size:25px;"></span><span class="igen">&nbsp;igen</span>
 <span class="points"><i class="fa fa-thumbs-o-up" style="font-size:24px"></i>Rigtige:  &nbsp;&nbsp;&nbsp; 0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <i class="fa fa-thumbs-o-down" style="font-size:24px"></i>Forkerte: &nbsp;&nbsp;&nbsp; 0</span>
</header>

<div class="container">
<div>
    <img class="img" src="img/cat.jpg" alt="cat" />
    <div class="answer">

    </div>
</div>

    <img class="img" src="img/beak.jpg" alt="beak" />
    <img class="img" src="img/spoon.jpg" alt="spoon" />
    <img class="img" src="img/milk.jpg" alt="milk" />

    <img class="img2" src="img/egg.jpg" alt="egg" />
    <img class="img2" src="img/thee.jpg" alt="tea" />
    <img class="img2" src="img/meel.jpg" alt="meel" />
    <img class="img2" src="img/passport.jpg" alt="passport" />
</div>

<footer>
<img class="dansk" id="dansk" src="img/dansk2.jpg" alt="dansk" />
<img class="sprint" id="sprint" src="img/sprint2.png" alt="sprint" />
<center><span class="copyright"> &copy;2013 laerdansk / FC-Sprint&sup2; Leerbedrijf bronnen </span></center>
</footer>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

我不确定你在寻找......

<html>
<title>test</title>
<head>
</head>
<body>
    <style>
    .top{background-color: #900; width: 100%; height: 100px;}
    .middle{background-color: #090; width: 100%; height: 600px; float: left;}
    .sidebar{background-color: #ccc; width: 10%; height: 600px; float: left;}
    .container{background-color: #000; width: 90%; height: 600px; float: left;}
    .row{background-color: #fff; width: 100%; height: 100px; float: left;}
    .footer{background-color: #090; width: 100%; height: 100px; float: left;}
    .slice{background-color: #069; width: 33%; height: 100px; float: left;}
    </style>
    <div class="top">top</div>
    <div class="middle">
        <div class="sidebar">sidebar</div>
        <div class="container">
            <div class="row">
                <div class="slice">1</div>
                <div class="slice">2</div>
                <div class="slice">3</div>
            </div>
            <div class="row">
                <div class="slice">1</div>
                <div class="slice">2</div>
                <div class="slice">3</div>
            </div>
            <div class="row">
                <div class="slice">1</div>
                <div class="slice">2</div>
                <div class="slice">3</div>
            </div>
        </div>
    </div>
    <div class="footer">
        footer
    </div>
</body>
</html>