html - 幻灯片框内的图像定位

标签 html css

我创建了一个包含图像的框,但我想做的是:

内联显示图像或将它们放置在彼此之上,然后使用 JQuery 在它们之间导航。

我已经在 .box.box img 以及 display: inline 上尝试了绝对定位,但它们弄乱了代码.

到这里为止:

.box {
    position: absolute;
    left: 10%;
    width: 80%;
    border: 10px solid white;
    border-radius: 10px;
    box-shadow: 0 0 4px black;
  }

  .box img {
    width: 100%;
  }

  .prev, .next {
    border: 1px solid black;
    padding: 5px;
  }

  .prev:Hover, .next:Hover {
    background-color: red;
    color: white;
    text-decoration: none;
  }
<div class="container-fluid">
<h1>Welcome Within</h1>
	<div class="box">
	  <img src="http://www.dan-dare.org/FreeFun/Images/PrinceOfPersiaWallpaper21024.jpg" />
		<img src="https://www.gamewallpapers.com/img_script/mobile_dir2/img.php?src=wallpaper_prince_of_persia_warrior_within_18_ipad.jpg&height=755&width=850&crop-to-fit" />
		<img src="https://r.mprd.se/media/images/66295-Prince_Of_Persia_Warrior_Within_READNFO-4.jpg" />
    <br /></br />
    <a href="#" class="prev">PREVIOUS</a>
    &nbsp;
    <a href="#" class="next">NEXT</a>
	</div>
  </div>

最佳答案

试试这个:

.box {
  position: absolute;
  left: 10%;
  width: 80%;
  border: 10px solid white;
  border-radius: 10px;
  box-shadow: 0 0 4px black;
  height: 300px;
  overflow: hidden;
  margin-bottom: 10px;
}

.caption {
  position: absolute;
  top: 10px;
  color: red;
  font-size: 20px;
  background: #fff;
  left: 30%;
}

.box img {
  width: 100%;
}

.prev,
.next {
  border: 1px solid black;
  padding: 5px;
}

.prev:Hover,
.next:Hover {
  background-color: red;
  color: white;
  text-decoration: none;
}
<div class="container-fluid">
  <h1>Welcome Within</h1>
  <div class="slider">
    <a href="#" class="prev">PREVIOUS</a>
    <a href="#" class="next">NEXT</a>
    <div class="box">
      <img src="http://www.dan-dare.org/FreeFun/Images/PrinceOfPersiaWallpaper21024.jpg" />
      <p class="caption">Caption1</p>
    </div>
    <div class="box">
      <img src="https://www.gamewallpapers.com/img_script/mobile_dir2/img.php?src=wallpaper_prince_of_persia_warrior_within_18_ipad.jpg&height=755&width=850&crop-to-fit" />
      <p class="caption">Caption2</p>
    </div>
    <div class="box">
      <img src="https://r.mprd.se/media/images/66295-Prince_Of_Persia_Warrior_Within_READNFO-4.jpg" />
      <p class="caption">Caption3</p>
    </div>
  </div>
</div>

关于html - 幻灯片框内的图像定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44094720/

相关文章:

javascript - 使用 localStorage 记住 ListView

html - 如何将 flexbox 包装在多行和多列上?

javascript - 确认框后关闭窗口

css - 如何仅使用CSS(不使用JS)预加载图像?

html - 我的网页在 IE 和 Firefox 中不工作

javascript - 网站中的媒体播放器是用什么语言编写的

php - 注销链接不起作用 php

javascript - 带有 @font-face 的自定义字体只在最后加载

jquery - jqGrid 寻呼机文本框大小

jquery - 如何在移动设备中向上移动 Div,在桌面设备中向下移动