Here is a very simple model that can serve as an example and for studies.
The main thing is that it uses the pseudo class :target
to change the opacity of the images and show them in large size. Another thing is that it uses "anchors" to navigate between an image and another.
In the example there is a <ul>
with thumbnails, and clicking on it with the :target
the big image appears. (In fact what appears is a "block" with all the elements inside, large image and navigation buttons. So when you change from one image to another you’re actually also changing the navigation btns, only you don’t notice this exchange visually by being an element in the same place of the other. Only the image you understand because they are different.)
Now let’s get down to the code!
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
width: 100%;
height: 100%;
}
.lbox {
visibility: hidden;
opacity: 0;
}
ul {
width: 800px;
list-style: none;
display: flex;
margin: 100px auto;
}
.min {
width: 200px;
padding: 10px;
}
.lbox:target {
opacity: 1;
visibility: visible;
width: 100%;
height: 100%;
top: 0;
left: 0;
position: fixed;
text-align: center;
background-color: rgba(10,10,10,0.7);
}
.box-img {
width: 1000px;
margin: 150px auto;
}
.btn {
color: #fff;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
text-decoration: none;
position: absolute;
width: 50px;
height: 50px;
font-size: 40px;
text-align: center;
}
#prev {
left: 5%;
top: 45%;
}
#next {
right: 5%;
top: 45%;
}
#close {
top: 0;
right: 2px;
}
.box-img img {
opacity: 0;
}
.lbox:target .box-img img {
opacity: 1;
transition: opacity 250ms linear;
}
<ul>
<li><a href="#img1"><img src="http://placecage.com/800/400" alt="" class="min"></a></li>
<li><a href="#img2"><img src="http://fillmurray.com/800/400" alt="" class="min"></a></li>
<li><a href="#img3"><img src="http://placecage.com/800/401" alt="" class="min"></a></li>
<li><a href="#img4"><img src="http://fillmurray.com/800/401" alt="" class="min"></a></li>
</ul>
<div class="lbox" id="img1">
<div class="box-img">
<a href="#img4" class="btn" id="prev">«</a>
<a href="#" class="btn" id="close">X</a>
<img src="http://placecage.com/800/400" alt="">
<a href="#img2" class="btn" id="next">»</a>
</div>
</div>
<div class="lbox" id="img2">
<div class="box-img">
<a href="#img1" class="btn" id="prev">«</a>
<a href="#" class="btn" id="close">X</a>
<img src="http://fillmurray.com/800/400" alt="">
<a href="#img3" class="btn" id="next">»</a>
</div>
</div>
<div class="lbox" id="img3">
<div class="box-img">
<a href="#img2" class="btn" id="prev">«</a>
<a href="#" class="btn" id="close">X</a>
<img src="http://placecage.com/800/401" alt="">
<a href="#img4" class="btn" id="next">»</a>
</div>
</div>
<div class="lbox" id="img4">
<div class="box-img">
<a href="#img3" class="btn" id="prev">«</a>
<a href="#" class="btn" id="close">X</a>
<img src="http://fillmurray.com/800/401" alt="">
<a href="#img1" class="btn" id="next">»</a>
</div>
</div>
OBS1: Some values are in PX so it is not 100% responsive, but this you can even arrange rss
OBS2: It is not dynamic, for each image you will have to create the block .lbox
new and do the "anchoring of links"
OBS3: Reference link to the example I used.
Do you already have any code? Post please.
– DiegoSantos
posted the code in the question and more or so
– Danilo rodrigues
but you’ve tried something with CSS or Javascript?
– Caique Romero
@Caiqueromero NO I so far did it right there
– Danilo rodrigues
Images are square or only miniature?
– Sam
@dvd are actually square normal image ,more thought to use css to decrease them . I’ll let them 200px by 200px and kind by clicking on it it open bigger more than I can change they know equal the face book images when we click to view bigger with the little boot to change the photos
– Danilo rodrigues
Here on the site there are several answers that can help you if you search something like, zoom image, enlarge image etc..
– Caique Romero
Possible duplicate of Increase image when user click on JS
– Caique Romero
Another solution that could give you an idea but not in the "click" but when hovering over: https://answall.com/a/246447/88202
– Caique Romero
@Caiqueromero the idea of using the Hover and cool and almost that that want to take a look at the link Aki
– Danilo rodrigues
From what I understand you want a "Photo Gallery", and YES, it is possible only with HTML and CSS. I’ll set a basic example for you, give me some time and I’ll answer you.
– hugocsl
@hugocsl thank you !
– Danilo rodrigues
It has several js plugins to do this.... now the tag
article
not to show photos, but text articles, with title, header, paragraph, those things. Semantically incorrect the way you mounted it. You could use the tagul
.– Karl Zillner
@Karlzillner actually was why I forget to take the < ul >, and the < article > and to separate each album
– Danilo rodrigues