Hello,
I'm Christine, I have just started coding and I'm trying to create a gallery page for a website.
I want to create a gallery like the one below. I want each image to have a hover effect that overlays with text two (two lines only)
and when I click on each image I want it to pop-up onto a page similar to this so that the image is larger and there is some text information giving a longer explanation.
This is the code I have so far, but I am not sure why it's not working properly.
Can I do this with only html, css and javascript? I don't want to use bootstrap or a plugin.
Thanks for your help
Christine
I'm Christine, I have just started coding and I'm trying to create a gallery page for a website.
I want to create a gallery like the one below. I want each image to have a hover effect that overlays with text two (two lines only)
and when I click on each image I want it to pop-up onto a page similar to this so that the image is larger and there is some text information giving a longer explanation.
This is the code I have so far, but I am not sure why it's not working properly.
Can I do this with only html, css and javascript? I don't want to use bootstrap or a plugin.
HTML:
<!-- Portfolio section -->
<div class="gallery-wraper">
<h1>Portfolio</h1>
<!-- Filtering buttons -->
<div class="button-area">
<button class="button">
<input type="checkbox" value="portraits" />Portraits
</label>
<label class="button">
<input type="checkbox" value="product" />Product
</label>
<label class="button">
<input type="checkbox" value="portraits" />Portraits
</label>
<label class="button">
<input type="checkbox" value="portraits" />Portraits
</label>
</div>
<!-- Galley images -->
<div class="gallery">
<div class="gallery-item">
<a href="">
<img src="img/woman-wearing-green-turban-3303918.jpg" alt="">
<div class="info">
<h5>Emily & Daniel</h5>
<p>Product photography</p>
</div>
</a>
</div>
<div class="gallery-item">
<a href="">
<img src="img/woman-wearing-green-turban-3303918.jpg" alt="">
<div class="info">
<h5>Emily & Daniel</h5>
<p>Product photography</p>
</div>
</a>
</div>
<div class="gallery-item">
<a href="">
<img src="img/woman-wearing-green-turban-3303918.jpg" alt="">
<div class="info">
<h5>Emily & Daniel</h5>
<p>Product photography</p>
</div>
</a>
</div>
<div class="gallery-item">
<a href="">
<img src="img/woman-wearing-green-turban-3303918.jpg" alt="">
<div class="info">
<h5>Emily & Daniel</h5>
<p>Product photography</p>
</div>
</a>
</div>
</div>
CSS:
CSS:
/*PORFOLIO*/
.gallery {
display: grid;
grid-template-columns: repeat (6, lfr);
grid-gap: 1rem;
}
.gallery-item img{
width: 100%;
height: 100%;
object-fit: cover;
}
.gallery-item:hover {
background-color: rgba(63, 73, 83, 0.85);
height: 100%;
left: 0;
opacity: 0;
position: absolute;
top: 0;
text-align: center;
width: 100%;
/*transition: .5s ease;*/
}
.info {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: rgba(63, 73, 83, 0.85);
}
.gallery-item:hover .info {
position: absolute;
text-align: center;
top: 25%;
width: 100%;
}
.gallery-item:hover, .overlay {
opacity: 1;
}
.info h5, p{
display: block;
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
text-align: center;
color: fff;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-80%, -50%);
text-align: center;
}
.gallery-item:nth-child(1) {
grid-column: span 4;
grid-row: span 2;
}
.gallery-item:nth-child(2),
.gallery-item:nth-child(3) {
grid-column: span 2;
}
.gallery-item:nth-child(4),
.gallery-item:nth-child(5) {
grid-column: span 3;
}
.gallery-item h1 {
font-family: Catamaran;
font-size: 28px;
font-weight: 600;
color: #111;
text-transform: uppercase;
text-align: center;
padding: 20px;
}
@media only screen and (max-width: 650px) {
.gallery {
display: block;
}
.gallery-item {
margin-bottom: 1rem;
}
.gallery h1 {
font-size: 28px;
}
*, *:before, *after {
box-sizing: border-box;
padding: 0;
margin: 0;
}
/*.gallery-item .hover .info {
top: 18%;
}*/
/*.gallery-img {
flex-basis: 300px;
}*/
}
/*Filter buttons*/
.button-area filters{
.button {
display: inline-block;
text-decoration: none;
padding: 10px;
margin: 30px 5px;
background-color: rgba(#fff,0.2);
border-radius: 3px;
cursor: pointer;
transition: all .3s ease;
&:hover{
background-color:rgba(#fff,0.32);
}
/* When the button is selected*/
&.active{
background-color: rgba(#fff,0.52);
box-shadow: 0 0 8px rgba(#000, 0.6) inset;
}
}
input[type=checkbox]{
display:none;
}
Thanks for your help
Christine
Last edited by a moderator: