如何在图像边框上放置导航箭头

时间:2018-12-19 17:47:26

标签: html css

我有一个“灯箱”类型的og图像查看器,用于浏览某些图像。

图像的纵横比不同,我需要将箭头放在边缘。当我调整网页大小时,图像会遵循网页的大小,这很好

但是,箭头只是从图像上浮下来:(有什么想法吗?

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)">&#10094;</div>
		<div class="next arrow" onclick="plusSlides(1)">&#10095;</div>
		<div class="close arrow" onclick="document.getElementById('lightBox').style.display='none'">&times;</div>
	</div>
</div>
	
</body>
</html>

0 个答案:

没有答案