html - 如何在图像边框上放置导航箭头
问题描述
我有一个“灯箱”类型的图像查看器,用于浏览一些图像。
图像具有不同的纵横比,我需要将箭头放在边缘。当我调整网页大小时,图像会跟随网页的大小,这非常好
然而,箭头只是漂浮在图像之外:(有什么想法吗?
body {
background-image: url("../img/bg-masthead.jpg");
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
margin: 0;
}
.modal {
position: fixed;
width: 100%;
height: 1000%;
background-color: rgba(0, 0, 0, 0.4);
/* display: none; */
}
.modal-content {
display: inline-block;
width: 95%;
height: 95%;
position: fixed;
top: 40px;
left: 50%;
transform: translate(-50%, 0);
}
img {
object-fit: contain;
max-width: 100%;
max-height: 100%;
width: auto;
height: auto;
display: block;
margin-left: auto;
margin-right: auto;
}
.prev {
top: 50%;
left: 8px;
}
.close {
top: 4px;
right: 8px;
}
.next {
top: 50%;
right: 8px;
}
.arrow {
position: absolute;
color: white;
font-weight: bold;
font-size: 50px;
cursor: pointer;
}
<!DOCTYPE html>
<html>
<title>Bilde galleri</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<link rel="stylesheet" type="text/css" href="css/test.css">
</head>
<body>
<div id="lightBox" class="modal">
<div class="modal-content" id="img_container">
<img id="largeImg" src="images/2007/Malayisa/IMG_0243.jpg">
<div class="prev arrow" onclick="plusSlides(-1)">❮</div>
<div class="next arrow" onclick="plusSlides(1)">❯</div>
<div class="close arrow" onclick="document.getElementById('lightBox').style.display='none'">×</div>
</div>
</div>
</body>
</html>
解决方案
推荐阅读
- android - 代码说找不到文件或目录
- multithreading - 需要有关攻击线程泄漏问题的帮助
- go - 如何使用 go 保存聚类模型?
- python - 如何在 SQLAlchemy 中将字节写入 Blob
- android - 单击通知打开应用程序时如何在对话框中恢复计时器
- c++ - 带有 MinGW 8.2.0 版和 Atom 文本编辑器的 C++ SFML
- oracle-apex - 在 TOMCAT 9 上安装 ORDS
- php - 尝试打印由发送到 2 个不同数组的正则表达式找到的数据以特定顺序打印出来
- composer-php - 为什么 Composer 的供应商文件夹中存在命名冲突?(在 bin 和 hhvm 之间)
- verilog - Verilog tranif1 nmos 仿真速度