1

我在 div 中有一个滑块#slides

<div id="slides">
          <img src="img/slide-1.jpg" />
          <img src="img/slide-2.jpg" />
          <img src="img/slide-3.jpg" />
          <img src="img/slide-4.jpg" />
    </div>

#slides { display: none; position:relative; }

现在我想.slide-helpext在显示一些文本的幻灯片图像中放置一个 div,我应该如何放置 div?

.slide-helpext
{
    position:absolute;
    top:30%;
    left:60px;

}

编辑:我将幻灯片 div 放置如下:

<div id="slides">
          <img src="img/example-slide-1.jpg" alt="Photo by: Missy S Link: http://www.flickr.com/photos/listenmissy/5087404401/">
          <div class="slide-helpext">1</div>
          <img src="img/example-slide-2.jpg" alt="Photo by: Daniel Parks Link: http://www.flickr.com/photos/parksdh/5227623068/">
          <div class="slide-helpext">2</div>
          <img src="img/example-slide-3.jpg" alt="Photo by: Mike Ranweiler Link: http://www.flickr.com/photos/27874907@N04/4833059991/">
          <div class="slide-helpext">3</div>
          <img src="img/example-slide-4.jpg" alt="Photo by: Stuart SeegerLink: http://www.flickr.com/photos/stuseeger/97577796/">
          <div class="slide-helpext">4</div>
    </div>

但是滑动数字然后图像,例如带有1的空白屏幕,然后是相应的图像!

4

2 回答 2

2

你可以这样做:

HTML:

<div id="slider">
    <div class="slide">
       <img src="img/slide-1.jpg" />
       <span class="slide-helpext">Caption goes here</span>
    </div>
    <div class="slide">
       <img src="img/slide-2.jpg" />
       <span class="slide-helpext">Caption goes here</span>
    </div>
    <div class="slide">
       <img src="img/slide-3.jpg" />
       <span class="slide-helpext">Caption goes here</span>
    </div>
</div>

CSS:

.slide{
    position:relative;
}
.slide-helpext{
    position:absolute;
    top:30%;
    left:60px;
}
于 2013-06-20T07:39:57.833 回答
0

将它放在它旁边,并给它一个负边距,使其与图像重叠。您实际上不能将其他元素分层放置在图像中,但您可以让它们看起来如此。

<div id="images">
    <img src="image.png" />
    <div class="text">Title</div>
</div>

CSS:

.text {
    margin-top: -30px;
    height:30px;
}
于 2013-06-20T07:31:42.443 回答