I'm using this layout and as you can see there is a section with 8 pictures on the bottom of the page - each of them is a hyperlink to the bigger image. It works pretty neat, esp. when you resize the page to smaller size, then the 4 cells becomes 2 and it looks like this. I want to change it a little, so that two first pictures are merged together, so the layout could look like this, and when the user resizes it, it would show him a proper layout like this. So far the html code for that specific part of the page looks like this:
<section class="screenshots" id="screenshots">
<div class="container-fluid">
<div class="row">
<ul class="grid">
<li>
<figure>
<img src="img/02-screenshot.jpg" alt="Screenshot 01">
<figcaption>
<div class="caption-content">
<a href="img/large/02.jpg" class="single_image">
<i class="fa fa-search"></i><br>
<p>User Centric Design</p>
</a>
</div>
</figcaption>
</figure>
</li>
<li>
<figure>
<img src="img/03-screenshot.jpg" alt="Screenshot 01">
<figcaption>
<div class="caption-content">
<a href="img/large/03.jpg" class="single_image">
<i class="fa fa-search"></i><br>
<p>Responsive and Adaptive</p>
</a>
</div>
</figcaption>
</figure>
</li>
<li>
<figure>
<img src="img/04-screenshot.jpg" alt="Screenshot 01">
<figcaption>
<div class="caption-content">
<a href="img/large/04.jpg" class="single_image">
<i class="fa fa-search"></i><br>
<p>Absolutely Free</p>
</a>
</div>
</figcaption>
</figure>
</li>
</ul>
</div>
<div class="row">
<ul class="grid">
<li>
<figure>
<img src="img/06-screenshot.jpg" alt="Screenshot 01">
<figcaption>
<div class="caption-content">
<a href="img/large/06.jpg" class="single_image">
<i class="fa fa-search"></i><br>
<p>Exclusive to Codrops</p>
</a>
</div>
</figcaption>
</figure>
</li>
<li>
<figure>
<img src="img/07-screenshot.jpg" alt="Screenshot 01">
<figcaption>
<div class="caption-content">
<a href="img/large/07.jpg" class="single_image">
<i class="fa fa-search"></i><br>
<p>Made with Love</p>
</a>
</div>
</figcaption>
</figure>
</li>
<li>
<figure>
<img src="img/08-screenshot.jpg" alt="Screenshot 01">
<figcaption>
<div class="caption-content">
<a href="img/large/08.jpg" class="single_image">
<i class="fa fa-search"></i><br>
<p>In Sydney, Australia</p>
</a>
</div>
</figcaption>
</figure>
</li>
</ul>
</div>
</div>
</section>
and the css code looks like this:
/* ==========================================================================
Screenshots Intro
========================================================================== */
.screenshots-intro {
padding: 170px 0 100px 0;
background-color: #f6f7f9;
}
.screenshots-intro h1 {
margin-bottom: 20px;
color: #24374b;
font-weight: 400;
font-size: 22px;
}
.screenshots-intro p {
margin-bottom: 25px;
color: #778899;
}
/* ==========================================================================
Screenshots
========================================================================== */
.screenshots ul {
margin: 0;
padding: 0;
width: 100%;
}
.screenshots ul li {
float: left;
min-height: 100%;
width: 25%;
background-color: #000;
list-style: none;
}
.screenshots figure {
position: relative;
overflow: hidden;
}
.screenshots figure img {
width: 100%;
height: 100%;
-webkit-transition: all 300ms ease-in-out;
transition: all 300ms ease-in-out;
}
.screenshots figure:hover img, .screenshots figure:focus img {
-webkit-transform: scale(1.1);
-ms-transform: scale(1.1);
transform: scale(1.1);
}
.screenshots figcaption {
position: absolute;
top: 0;
left: 0;
padding: 25% 0;
width: 100%;
height: 100%;
background-color: rgba(63, 97, 132, 0.85);
text-align: center;
font-size: 15px;
opacity: 0;
-webkit-transition: all 300ms ease-in-out;
transition: all 300ms ease-in-out;
}
.screenshots figcaption a {
color: #fff
}
.screenshots figcaption a:hover, .screenshots figcaption a:focus {
color: #73d0da
}
.screenshots figure:hover figcaption, .screenshots figure:focus figcaption {
opacity: 1
}
.visible {
opacity: 1
}
.screenshots figure.cs-hover figcaption {
opacity: 1
}
.screenshots figcaption i {
font-size: 35px
}
.screenshots figcaption p {
margin-bottom: 0;
text-transform: uppercase;
font-weight: 400;
}
.screenshots figcaption .caption-content {
position: absolute;
top: 50%;
left: 50%;
margin-top: -40px;
margin-left: -100px;
width: 200px;
-webkit-transform: translate(0px, 15px);
-ms-transform: translate(0px, 15px);
transform: translate(0px, 15px);
-webkit-transition: all 300ms ease-in-out;
transition: all 300ms ease-in-out;
}
.screenshots figure:hover figcaption .caption-content, .screenshots figure:focus figcaption .caption-content {
-webkit-transform: translate(0px, 0px);
-ms-transform: translate(0px, 0px);
transform: translate(0px, 0px);
}
I know it's a lot of code, but maybe anyone of you have the idea of how to change this particular part of the layout to have it as I included in the pictures? Thanks.
This is the updated answer.
I am attaching the code and jsfiddle link with it.
Just replace the src of the images with yours to see the results.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<style type="text/css">
.container {
width: 100%;
margin: 0 auto;
}
img {
max-width: 100%;
}
/* this css is just for understanding */
.a {
background-color: red;
}
.b {
background-color: green;
}
.c {
background-color: blue;
}
.d {
background-color: black;
}
/* this css is just for understanding */
/* this is the logic to change the positions of image */
#media (min-width: 320px) {
.a,
.b,
.c,
.d {
width: 100%;
float: left;
}
}
#media (min-width: 768px) {
.a,
.b,
.c,
.d {
width: 50%;
float: left;
}
}
</style>
<body>
<div class="container">
<div class="a">
<img src="img/1.png" height="222" width="581">
</div>
<div class="b">
<img src="img/2.jpg" height="222" width="581">
</div>
<div class="c">
<img src="img/3.jpg" height="222" width="581">
</div>
<div class="d">
<img src="img/4.png" height="222" width="581">
</div>
</div>
</body>
</html>
this is the jsfiddle link
Related
I'm new in web programming and I am trying to build from scratch a static art portfolio website that can be responsive. I've been recommended for the layout that I wanted to use CSS Grid, I am also combining containers using flexbox for the content that goes inside it. The structure that I have in my website is the following:
Navbar
Header
Content
Image of the concept of my website
Basically I wanted the lateral vertical navbar to be in a fixed position, so the user can scroll down while that stays in the same place. I did achieve that using the property position: fixed but I believe that's perhaps provoking part of the grid it's not being adjusted within the navbar and it gets pushed to the right side while changing the size of the window and the gallery in "content" gets displaced underneath the navbar. The affected element is "content" (forgive the repetiveness of the names / words). The issue happens predominantly on Chromium based browsers.
So basically both the grid element called "content" and the items within that structure (which are using flexbox) are having issues.
What I tried so far:
I have some #media properties too established in my CSS for adjusting
the navbar while scaling down. I tried to see if deleting that
property would fix the problem but it's still the same.
I tried deleting the gallery that I've put inside "content" to see if
that fixes the issue but it doesn't.
Honestly, I am really not sure what to do to fix the problem. Is probably very silly what's going on but I don't know how to solve it.
The code in my website:
#import url('https://fonts.googleapis.com/css2?family=Raleway:ital,wght#0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
list-style: none;
text-decoration: none;
background-color: none;
font-family: 'Raleway', sans-serif;
scroll-behavior: smooth;
/* Adjust font size */
-webkit-text-size-adjust: 100%;
/* Font variant */
font-variant-ligatures: none;
-webkit-font-variant-ligatures: none;
/* Smoothing */
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
letter-spacing: 0.7px;
#-webkit-keyframes rotate-forever {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg); }
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg); } }
#-moz-keyframes rotate-forever {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg); }
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg); } }
#keyframes rotate-forever {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg); }
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg); } }
}
/* Basic structure */
.grid {
animation: fadein 2s;
}
#keyframes fadein {
from { opacity: 0}
to { opacity: 1}
}
.grid {
display: grid;
grid-template-rows: 1fr fr 1fr;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
}
#navbar {
background-color: #3c5d79;
grid-row-start: 1;
grid-column-start: 1;
grid-row-end: 3;
grid-column-end: 1;
padding: 3vw;
align-content: center;
text-align: center;
color: #f4d3cc;
height: 100vh;
width: 40vh;
position: fixed;
position: fixed; /* Fixed Sidebar (stay in place on scroll) */
z-index: 1; /* Stay on top */
top: 0; /* Stay at the top */
left: 0;
}
#header2 {
background-color: #f2f2f5;
grid-row-start: ;
grid-column-start: 2;
grid-row-end: 2;
grid-column-end: 6;
height: 15vh;
}
#header {
background-color: #f4d3cc;
grid-row-start: ;
grid-column-start: 2;
grid-row-end: 2;
grid-column-end: 6;
height: 15vh;
}
#content {
background-color: #f2f2f5;
grid-row-start: 2;
grid-column-start: 2;
height: 100%;
grid-row-end: 3;
grid-column-end: 6;
}
/* styling */
/* -------NAVBAR STYLING START-------- */
a,
a:hover,
a:focus,
a:active {
text-decoration: none;
color: inherit;
}
a:hover {
color: white;
}
a {
transition: color 500ms ease 0.1s;
}
.contnav {
display: flex;
flex-direction: column;
align-content: center;
text-align: center;
padding-top: 20%;
text-align: center;
align-content: center;
line-height: 30px;
color: #f4d3cc;
}
/* Line height is provoking the grid to break */
.work-nav {
margin-top: 15%;
margin-bottom: 5%;
font-weight: 700;
font-size: 13px;
color: #f4d3cc;
}
.logo-nav {
margin-top: 10px;
display: flex;
flex-direction: column;
align-content: center;
font-weight: 700;
font-size: 1.5rem;
color: #f4d3cc;
}
.divbar {
border-top: 1.5px solid #bbb;
margin: 15px;
height: 0px;
color: #3c5d79;
}
.divbar1 {
border-top: 2px solid #bbb;
margin: 27px;
}
.items-nav {
}
.items-nav2 {
display: flex;
flex-direction: column;
align-content: center;
text-align: center;
padding-top: 100px;
}
.division {
padding: 10px;
}
.info-nav2 {
font-weight: 700;
}
.icons {
display: flex;
align-items: center;
padding-top: 70%;
justify-content: space-around;
}
.circle1 {
width: 10px;
height: 10px;
background: #f4d3cc;
border-radius: 50%
}
.circle2 {
width: 10px;
height: 10px;
background: #f4d3cc;
border-radius: 50%
}
.circle3 {
width: 10px;
height: 10px;
background: #f4d3cc;
border-radius: 50%
}
/* -------NAVBAR STYLING END-------- */
/* -------HEADER STYLING START-------- */
.navmarg {
padding-left: 20px;
}
.info-header2 {
padding-top: 25px;
display: flex;
margin: 20px;
font-size: 1.3rem;
font-weight: 300;
color: #3c5d79;
}
.info-header {
margin-top: 34px;
margin-bottom: 34px;
display: flex;
justify-content: center;
font-size: 2.5rem;
font-weight: 300;
color: #3c5d79;
}
/* -------HEADER STYLING END-------- */
/* -------CONTENT STYLING START-------- */
.contbox {
display: flex;
align-content: center;
margin: 1vh;
color: #595959;
display: flex;
margin: 15px;
padding: 2%;
font-size: 1rem;
margin-left: 10%;
margin-right: 10%;
}
/* -------CONTENT STYLING END-------- */
/* -------GALLERY-------- */
.gallery-container {
display: flex;
align-content: center;
padding-left: 30px;
}
.image-gallery {
width: 100%;
max-width: 1150px;
margin: 0 auto;
padding: 50px 20px;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
grid-auto-rows: 250px;
grid-auto-flow: dense;
grid-gap: 20px;
}
.image-gallery .image-box {
position: relative;
background-color: #d7d7d8;
overflow: hidden;
}
.image-gallery .image-box:nth-child(7n + 1) {
grid-column: span 2;
grid-row: span 2;
}
.image-gallery .image-box img {
width: 100%;
height: 100%;
object-fit: cover;
transition: all 0.5s ease;
}
.image-gallery .image-box:hover img {
transform: scale(1.1);
}
.image-gallery .image-box .overlay {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #fafafaf2;
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
transition: all 0.5s ease;
z-index: 1;
}
.image-gallery .image-box:hover .overlay {
top: 20px;
right: 20px;
bottom: 20px;
left: 20px;
opacity: 1;
}
.image-gallery .image-box .details {
text-align: center;
}
.image-gallery .image-box .details .title {
margin-bottom: 8px;
font-size: 24px;
font-weight: 600;
position: relative;
top: -5px;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
}
.image-gallery .image-box .details .category {
font-size: 18px;
font-weight: 400;
position: relative;
bottom: -5px;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
}
.image-gallery .image-box:hover .details .title {
top: 0px;
opacity: 1;
visibility: visible;
transition: all 0.3s 0.2s ease;
}
.image-gallery .image-box:hover .details .category {
bottom: 0;
opacity: 1;
visibility: visible;
transition: all 0.3s 0.2s ease;
}
.image-gallery .image-box .details .title a,
.image-gallery .image-box .details .category a {
color: #222222;
text-decoration: none;
}
/* Let's make it responsive */
#media (max-width: 768px) {
.image-gallery {
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
grid-auto-rows: 250px;
}
.image-gallery .image-box:nth-child(7n + 1) {
grid-column: unset;
grid-row: unset;
}
}
#media screen and (max-width: 1200px) {
#navbar {
width: 26%;
}
#navbar .logo-nav {
font-size: 100% !important;
}
#navbar li {
font-size:100%; !important;
}
.d {
display: none;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Inicio - Portfolio</title>
<link rel="stylesheet" href="css/style.css">
<script type="text/javascript" src="js/java.js"></script>
</head>
<body>
<div class="grid">
<div id="navbar">
<div class="logo-nav">PORTFOLIO</div>
<div class="divbar1"></div>
<div class="contnav">
<div class="work-nav">WORK</div>
<div class="items-nav">
<ul>
<li><i class="Animation"></i>Animation</li>
<li><i class="Rough"></i>Rough</li>
<li><i class="Original Art"></i>Original Art</li>
<li><i class="Graphic Design"></i>Graphic Design</li>
<li><i class="Character design"></i>Character Design</li>
</ul>
</div>
<div class="items-nav2">
<ul>
<li>
<div class="info-nav2">About me</div>
</li>
<li><i class="contact"></i>Contact</li>
</ul>
<div class="icons">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
</div>
</div>
</div>
</div>
<!--<div id="header2">
<div class="navmarg">
<p class="info-header2">ORIGINAL ART</p>
<div class="divbar"></div>
</div>
</div>-->
<div id="header">
<p class="info-header">WORK</p>
</div> -->
<div id="content">
<!-- <div class="contbox">
00
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pjjjariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div> -->
<div class="gallery-container">
<div class="image-gallery">
<div class="image-box">
<img src="images/5.png" alt="img.jpg" />
<div class="overlay">
<div class="details">
<h3 class="title">
Original Art
</h3>
<span class="category">
Category
</span>
</div>
</div>
</div>
<div class="image-box">
<img src="images/2.jpg" alt="img.jpg" />
<div class="overlay">
<div class="details">
<h3 class="title">
Your Title
</h3>
<span class="category">
Category
</span>
</div>
</div>
</div>
<div class="image-box">
<img src="images/3.jpg" alt="img.jpg" />
<div class="overlay">
<div class="details">
<h3 class="title">
Your Title
</h3>
<span class="category">
Category
</span>
</div>
</div>
</div>
<div class="image-box">
<img src="images/7.png" alt="img.jpg" />
<div class="overlay">
<div class="details">
<h3 class="title">
Your Title
</h3>
<span class="category">
Category
</span>
</div>
</div>
</div>
<div class="image-box">
<img src="images/11.png" alt="img.jpg" />
<div class="overlay">
<div class="details">
<h3 class="title">
Your Title
</h3>
<span class="category">
Category
</span>
</div>
</div>
</div>
<div class="image-box">
<img src="images/6.png" alt="img.jpg" />
<div class="overlay">
<div class="details">
<h3 class="title">
Your Title
</h3>
<span class="category">
Category
</span>
</div>
</div>
</div>
<div class="image-box">
<img src="images/4.jpg" alt="img.jpg" />
<div class="overlay">
<div class="details">
<h3 class="title">
Your Title
</h3>
<span class="category">
Category
</span>
</div>
</div>
</div>
<div class="image-box">
<img src="images/img-5.jpg" alt="img.jpg" />
<div class="overlay">
<div class="details">
<h3 class="title">
Your Title
</h3>
<span class="category">
Category
</span>
</div>
</div>
</div>
<div class="image-box">
<img src="images/img-6.jpg" alt="img.jpg" />
<div class="overlay">
<div class="details">
<h3 class="title">
Your Title
</h3>
<span class="category">
Category
</span>
</div>
</div>
</div>
<div class="image-box">
<img src="images/img-4.jpg" alt="img.jpg" />
<div class="overlay">
<div class="details">
<h3 class="title">
Your Title
</h3>
<span class="category">
Category
</span>
</div>
</div>
</div>
<div class="image-box">
<img src="images/img-10.jpg" alt="img.jpg" />
<div class="overlay">
<div class="details">
<h3 class="title">
Your Title
</h3>
<span class="category">
Category
</span>
</div>
</div>
</div>
<div class="image-box">
<img src="images/img-7.jpg" alt="img.jpg" />
<div class="overlay">
<div class="details">
<h3 class="title">
Your Title
</h3>
<span class="category">
Category
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
This would be my approach:
Media queries are used to add complexity rather than remove it
Grid and flex are used instead of absolute positioning
I've set you up with some custom props for your colours, but you'll have to go through and finish that
#import url("https://fonts.googleapis.com/css2?family=Raleway:ital,wght#0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
:root {
--headerBackground: #3c5d79;
--headerText: #f4d3cc;
--mainBackground: #f2f2f5;
--mainHeaderBackground: #f4d3cc;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
list-style: none;
text-decoration: none;
background-color: none;
font-family: "Raleway", sans-serif;
scroll-behavior: smooth;
font-variant-ligatures: none;
text-rendering: optimizeLegibility;
letter-spacing: 0.7px;
}
a:link,
a:hover,
a:focus,
a:active {
text-decoration: none;
color: inherit;
}
a:hover {
color: white;
}
a {
transition: color 500ms ease 0.1s;
}
body {
display: grid;
}
.main-header {
display: flex;
flex-flow: column nowrap;
justify-content: space-around;
align-items: center;
min-height: 100vh;
padding: 3vw;
background-color: var(--headerBackground);
color: var(--headerText);
}
.main-header h1 {
font-weight: 700;
font-size: 1.5rem;
padding: 1.3em;
border-bottom: 1.5px solid #bbb;
}
.main-header li {
padding-block: 1em;
}
.main-header li li {
padding-block: 0.5em;
}
.main-header .icons {
width: 100%;
display: flex;
align-items: center;
justify-content: space-around;
}
.main-header .circle {
width: 10px;
height: 10px;
background: #f4d3cc;
border-radius: 50%;
}
.info-header {
font-size: 2.5rem;
font-weight: 300;
text-align: center;
padding: 2rem;
background-color: var(--mainHeaderBackground);
color: #3c5d79;
}
.image-gallery {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
grid-auto-rows: 250px;
grid-auto-flow: dense;
margin: 0 auto;
padding: 4rem 2rem;
grid-gap: 1.5rem;
}
.image-gallery .image-box:nth-child(7n + 1) {
grid-area: span 2 / span 2;
}
.image-box {
position: relative;
background-color: #d7d7d8;
}
.image-box img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
.image-box .overlay {
position: absolute;
inset: 0;
display: grid;
place-content: center;
transition: all 0.5s ease;
opacity: 0;
background-color: #fafafaf2;
color: #222;
text-align: center;
}
.image-box:hover {
cursor: pointer;
transform: scale(1.1);
}
.image-box:hover .overlay {
opacity: 1;
}
#media (min-width: 50rem) {
body {
grid-template-columns: 1fr 3fr;
max-height: 100vh;
}
header {
max-height: 100vmax;
}
main {
max-height: 100vh;
overflow: auto;
}
}
<header class="main-header">
<h2 class="logo-nav">PORTFOLIO</h2>
<nav>
<ul class="contnav">
<li>
<h2 class="work-nav">WORK</h2>
<ul>
<li>
<i class="Animation"></i>Animation
</li>
<li>
<i class="Rough"></i>Rough
</li>
<li>
<i class="Original Art"></i>Original Art
</li>
<li>
<i class="Graphic Design"></i>Graphic Design
</li>
<li>
<i class="Character design"></i>Character Design
</li>
</ul>
</li>
<li>
<ul>
<li>
<div class="info-nav2">About me</div>
</li>
<li>
<i class="contact"></i>Contact
</li>
</ul>
</li>
</ul>
</nav>
<div class="icons">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
</div>
</header>
<main>
<header class="info-header">
<h2>WORK</h2>
</header>
<section class="image-gallery">
<figure class="image-box">
<img src="https://source.unsplash.com/random/500x500" alt="Original Art" />
<figcaption class="overlay">
<h3 class="title">
Original Art
</h3>
<a class="category" href="#">Category</a>
</figcaption>
</figure>
<figure class="image-box">
<img src="https://source.unsplash.com/random/500x500" alt="Original Art" />
<figcaption class="overlay">
<h3 class="title">
Original Art
</h3>
<a class="category" href="#">Category</a>
</figcaption>
</figure>
<figure class="image-box">
<img src="https://source.unsplash.com/random/500x500" alt="Original Art" />
<figcaption class="overlay">
<h3 class="title">
Original Art
</h3>
<a class="category" href="#">Category</a>
</figcaption>
</figure>
<figure class="image-box">
<img src="https://source.unsplash.com/random/500x500" alt="Original Art" />
<figcaption class="overlay">
<h3 class="title">
Original Art
</h3>
<a class="category" href="#">Category</a>
</figcaption>
</figure>
<figure class="image-box">
<img src="https://source.unsplash.com/random/500x500" alt="Original Art" />
<figcaption class="overlay">
<h3 class="title">
Original Art
</h3>
<a class="category" href="#">Category</a>
</figcaption>
</figure>
<figure class="image-box">
<img src="https://source.unsplash.com/random/500x500" alt="Original Art" />
<figcaption class="overlay">
<h3 class="title">
Original Art
</h3>
<a class="category" href="#">Category</a>
</figcaption>
</figure>
<figure class="image-box">
<img src="https://source.unsplash.com/random/500x500" alt="Original Art" />
<figcaption class="overlay">
<h3 class="title">
Original Art
</h3>
<a class="category" href="#">Category</a>
</figcaption>
</figure>
<figure class="image-box">
<img src="https://source.unsplash.com/random/500x500" alt="Original Art" />
<figcaption class="overlay">
<h3 class="title">
Original Art
</h3>
<a class="category" href="#">Category</a>
</figcaption>
</figure>
<figure class="image-box">
<img src="https://source.unsplash.com/random/500x500" alt="Original Art" />
<figcaption class="overlay">
<h3 class="title">
Original Art
</h3>
<a class="category" href="#">Category</a>
</figcaption>
</figure>
<figure class="image-box">
<img src="https://source.unsplash.com/random/500x500" alt="Original Art" />
<figcaption class="overlay">
<h3 class="title">
Original Art
</h3>
<a class="category" href="#">Category</a>
</figcaption>
</figure>
<figure class="image-box">
<img src="https://source.unsplash.com/random/500x500" alt="Original Art" />
<figcaption class="overlay">
<h3 class="title">
Original Art
</h3>
<a class="category" href="#">Category</a>
</figcaption>
</figure>
<figure class="image-box">
<img src="https://source.unsplash.com/random/500x500" alt="Original Art" />
<figcaption class="overlay">
<h3 class="title">
Original Art
</h3>
<a class="category" href="#">Category</a>
</figcaption>
</figure>
</section>
</main>
I would like to increase the height of my images to 400px. However the images don't fill the div while maintaining the aspect ratio.
I previously added height:100% to my images while adding a fixed height of 400px to my parent div, then adding object-fit: cover to the images. However, on page resize, the images do not maintain their ratio and instead squash / collapse.
Any help would be great. Thank you.
#test {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
#test h2 {
font-family: 'Poppins';
text-transform: uppercase;
font-weight: 600;
font-size: 1.3em;
color: #333;
margin-bottom: 20px;
}
#picwrapper {
width: 85%;
}
#media only screen and (max-width: 986px) {
#picwrapper {
flex-direction: column;
}
}
#picwrapper {
display: flex;
flex-wrap: wrap;
}
.third {
width: 33.3333333333%;
position: relative;
}
#media only screen and (max-width: 986px) {
.third {
width: 100%;
}
}
.third img {
max-width: 100%;
height: auto;
display: block;
padding-top: 10%;
/* 4:3 Aspect Ratio */
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background: linear-gradient(rgba(25, 25, 25, 0.9), rgba(25, 25, 25, 0.9));
}
.overlay-text {
font-family: 'Poppins';
font-weight: 500;
}
.third:hover .overlay {
opacity: 1;
}
.overlay-text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
<section id="test">
<div id="picwrapper">
<div class="third">
<img src="https://cdn.zmescience.com/wp-
content/uploads/2018/11/Magnificent_CME_Erupts_on_the_Sun_-_August_31.jpg">
<a href="AUDI/audi.html">
<div class="overlay">
<h1 class="overlay-text">Parkash Sandhu</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://solarsystem.nasa.gov/system/news_items/main_images/853_ph3_waxing_gibbous_2k.jpg">
<a href="#">
<div class="overlay">
<h1 class="overlay-text">Flo Music</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://cdn.zmescience.com/wp-content/uploads/2018/11/Magnificent_CME_Erupts_on_the_Sun_-_August_31.jpg">
<a href="#">
<div class="overlay">
<h1 class="overlay-text">British Athletics</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://solarsystem.nasa.gov/system/news_items/main_images/853_ph3_waxing_gibbous_2k.jpg">
<a href="AUDI/audi.html">
<div class="overlay">
<h1 class="overlay-text">Audi</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://cdn.zmescience.com/wp-
content/uploads/2018/11/Magnificent_CME_Erupts_on_the_Sun_-
_August_31.jpg">
<a href="Virgin Atlantic">
<div class="overlay">
<h1 class="overlay-text">Virgin Atlantic</h1>
</div>
</a>
</div>
</div>
</section>
In what follows, I'm making some assumptions about what you're after.
I'm assuming that you want the images to maintain their aspect ratio (4:3) at all times, but still scale larger and smaller proportionally as the screen grows/shrinks.
Below, you'll find a different implementation of your code, but one that I think captures what you're going for. At least, maybe it'll get you going in the right direction.
(BTW, Credit to Andy Bell for this aspect ratio technique. See here: https://andy-bell.design/wrote/creating-an-aspect-ratio-css-utility/)
[class*="aspect-ratio-"] {
display: block;
position: relative;
width: 100%;
}
[class*="aspect-ratio-"] > * {
display: block;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.aspect-ratio-tv {
padding-top: 75%; /* 4:3 */
}
.gallery {
display: flex;
flex-wrap: wrap;
list-style: none;
padding: 0;
margin: 0;
}
.gallery {
width: 100%;
}
.gallery li {
flex-basis: 100%;
}
#media screen and (min-width: 580px) {
.gallery li {
flex-basis: 50%;
}
}
#media screen and (min-width: 960px) {
.gallery li {
flex-basis: 33.33333%;
}
}
.gallery img {
object-fit: cover;
}
.overlay {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: 0.5s ease;
background: linear-gradient(rgba(25, 25, 25, 0.9), rgba(25, 25, 25, 0.9));
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
}
.overlay-text {
color: white;
font-size: 20px;
text-decoration: none;
}
.overlay:hover {
opacity: 1;
text-decoration: none;
}
<ul class="gallery">
<li>
<div class="aspect-ratio-tv">
<img src="https://source.unsplash.com/phvbkGThElM/800x600" alt="A neon ferris wheel" loading="lazy" />
<a href="#0" class="overlay">
<h1 class="overlay-text">
TEST HEADING
</h1>
</a>
</div>
</li>
<li>
<div class="aspect-ratio-tv">
<img src="https://source.unsplash.com/H_mTtLykvKs/800x682" alt="A dimly lit drum kit" loading="lazy" />
<a href="#0" class="overlay">
<h1 class="overlay-text">
TEST HEADING
</h1>
</a>
</div>
</li>
<li>
<div class="aspect-ratio-tv">
<img src="https://source.unsplash.com/Hc42xXu_WOg/800x567" alt="Blueberries, close up" loading="lazy" />
<a href="#0" class="overlay">
<h1 class="overlay-text">
TEST HEADING
</h1>
</a>
</div>
</li>
<li>
<div class="aspect-ratio-tv">
<img src="https://source.unsplash.com/MfynxC5_tiU/800x999" alt="High angle waterfall" loading="lazy" />
<a href="#0" class="overlay">
<h1 class="overlay-text">
TEST HEADING
</h1>
</a>
</div>
</li>
<li>
<div class="aspect-ratio-tv">
<img src="https://source.unsplash.com/7ZTx1iA7a7Q/800x397" alt="Sunset coastal scence" loading="lazy" />
<a href="#0" class="overlay">
<h1 class="overlay-text">
TEST HEADING
</h1>
</a>
</div>
</li>
<li>
<div class="aspect-ratio-tv">
<img src="https://source.unsplash.com/pRvy1j4aINE/800x785" alt="High angle shot of a recording studio" loading="lazy" />
<a href="#0" class="overlay">
<h1 class="overlay-text">
TEST HEADING
</h1>
</a>
</div>
</li>
</ul>
See here for a pen: https://codepen.io/anon/pen/oOeBOj
Dont specify a width, just height.
.moon
{
height: 100%;
}
Specifying a width and height will squash the images; just specify the height.
img {
height: 50%; /*Change this to what you want.*/
}
#test {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
#test h2 {
font-family: 'Poppins';
text-transform: uppercase;
font-weight: 600;
font-size: 1.3em;
color: #333;
margin-bottom: 20px;
}
#media only screen and (max-width: 986px) {
#picwrapper {
flex-direction: column;
}
}
#picwrapper {
display: flex;
flex-wrap: wrap;
}
.third {
width: 33.3333333333%;
position: relative;
}
#media only screen and (max-width: 986px) {
.third {
width: 100%;
}
}
.third img {
height: auto;
display: block;
padding-top: 10%;
/* 4:3 Aspect Ratio */
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background: linear-gradient(rgba(25, 25, 25, 0.9), rgba(25, 25, 25, 0.9));
}
.overlay-text {
font-family: 'Poppins';
font-weight: 500;
}
.third:hover .overlay {
opacity: 1;
}
.overlay-text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
<section id="test">
<div id="picwrapper">
<div class="third">
<img src="https://cdn.zmescience.com/wp-
content/uploads/2018/11/Magnificent_CME_Erupts_on_the_Sun_-_August_31.jpg">
<a href="AUDI/audi.html">
<div class="overlay">
<h1 class="overlay-text">Parkash Sandhu</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://solarsystem.nasa.gov/system/news_items/main_images/853_ph3_waxing_gibbous_2k.jpg">
<a href="#">
<div class="overlay">
<h1 class="overlay-text">Flo Music</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://cdn.zmescience.com/wp-content/uploads/2018/11/Magnificent_CME_Erupts_on_the_Sun_-_August_31.jpg">
<a href="#">
<div class="overlay">
<h1 class="overlay-text">British Athletics</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://solarsystem.nasa.gov/system/news_items/main_images/853_ph3_waxing_gibbous_2k.jpg">
<a href="AUDI/audi.html">
<div class="overlay">
<h1 class="overlay-text">Audi</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://cdn.zmescience.com/wp-
content/uploads/2018/11/Magnificent_CME_Erupts_on_the_Sun_-
_August_31.jpg">
<a href="Virgin Atlantic">
<div class="overlay">
<h1 class="overlay-text">Virgin Atlantic</h1>
</div>
</a>
</div>
</div>
</section>
I have created a grid of images with a hover effect. When you hover over the images it zooms in. It is working fine on safari but when I try it out on google chrome the images disappear when you hover over them instead of the zoom effect. I have provided my code below.
HTML :
<body>
<div class="message0">
<img
src="https://cdn.shopify.com/s/files/1/1312/0159/files/shutterstock_134800463.jpg?11249922432265530300" />
Wakeup And Makeup <img
src="https://cdn.shopify.com/s/files/1/1312/0159/files/shutterstock_134800463.jpg?11249922432265530300" />
</div>
<div class="masonry">
<div class="fader0">
<div class="item">
<img
src="https://cdn.shopify.com/s/files/1/1312/0159/files/shutterstock_113634307.jpg?3027373344113436523" />
</div>
</div>
<div class="my-wrapper">
<div class="item">
<a href="https://vipera-nyc.myshopify.com/collections/eyeshadow"><img
src="https://cdn.shopify.com/s/files/1/1312/0159/files/Vipera_cae46bcd-7bd4-4ed6-ab7d-5970f5d6fa44.jpg?5440451544572147338" /></a>
</div>
</div>
<div class="fader1">
<div class="item">
<img
src="https://cdn.shopify.com/s/files/1/1312/0159/files/shutterstock_313764047.jpg?453596164489734443" />
</div>
</div>
<div class="item">
<img
src="https://cdn.shopify.com/s/files/1/1312/0159/files/HelloG-5.jpg?7272790211589801407" />
</div>
<div class="fader">
<div class="item">
<img
src="https://cdn.shopify.com/s/files/1/1312/0159/files/EYEScool.jpg?3027373344113436523" />
</div>
</div>
<div class="item">
<img
src="https://cdn.shopify.com/s/files/1/1312/0159/files/shutterstock_91130072.jpg?3027373344113436523" />
</div>
<div class="item">
<img
src="https://cdn.shopify.com/s/files/1/1312/0159/files/Makeup-2.jpg?7468684895134417704" />
</div>
<div class="my-wrapper">
<div class="item">
<a href="https://twitter.com/ViperaNYC"><img
src="https://cdn.shopify.com/s/files/1/1312/0159/files/Tweet_us_your_look.jpg?453596164489734443" /></a>
</div>
</div>
<div class="item">
<img
src="https://cdn.shopify.com/s/files/1/1312/0159/files/glosssssss_5c5c5520-ea20-4c78-8830-e633e5bb1083.jpg?1992342090983963689" />
</div>
<div class="item">
<div class="my-wrapper">
<a
href="https://vipera-nyc.myshopify.com/collections/best-selling-products">
<img
src="https://cdn.shopify.com/s/files/1/1312/0159/files/Best_Selling_Products-3.jpg?887070778965157300" />
</a>
</div>
</div>
</div>
</body>
CSS:
.item img { /* Masonry bricks or child elements */
background-color: #eee;
display: inline-block;
margin: 0 0 1em;
width: 100%;
}
.itemkat img {
background-color: #eee;
display: inline-block;
margin: 0 0 1em;
width:100%;
}
.grid {
column-count: 3;
-webkit-column-gap: -10px; /* Chrome, Safari, Opera */
-moz-column-gap: -10px; /* Firefox */
column-gap: -10px;
line-height:100%;
}
.grid-item{
background-color: #eee;
display: inline-block;
margin: 0 0 1em;
width: 100%;
}
.message0
{
display:center;
font-size:30px;
}
.my-wrapper {
background-color: #f2f2f2;
}
.my-wrapper:hover img {
opacity:0.2;
}
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
}
.item {
position: relative;
/* margin: 0%; /*makes left margin closer */
overflow: hidden;
width: 470px;
}
.item img {
max-width: 100%; /*reduces space between images */
overflow: hidden;
-moz-transition: all 0.3s;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.item:hover img {
overflow: hidden;
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
.message0 {
font-family: Brush Script MT ;
font-size:120px;
text-align:center;
color:black;
letter-spacing: 5px;
}
I have provided a fiddle. ***IT WORKS ON OTHER INTERNET BROWSERS BUT NOT GOOGLE CHROME WHICH IS THE PROBLEM****
https://jsfiddle.net/getMecoffee56/o11hmwek/1/
I am trying to make a gallery, the links show up from the bottom on
hover. I am having trouble regarding hiding them when they are not on hover.
I am trying to make a gallery, the links show up from the bottom on
hover. I am having trouble regarding hiding them when they are not on hover.
I am trying to make a gallery, the links show up from the bottom on
hover. I am having trouble regarding hiding them when they are not on hover.
I am trying to make a gallery, the links show up from the bottom on
hover. I am having trouble regarding hiding them when they are not on hover.
I am trying to make a gallery, the links show up from the bottom on
hover. I am having trouble regarding hiding them when they are not on hover.
.imageWrapper {
position: relative;
width: 200px;
height: 200px;
display: inline-block;
padding: 0px;
margin: 0px;
}
.imageWrapper img {
display: block;
width: 200px;
height: 200px;
padding: 0px;
margin: 0px;
}
.imageWrapper .cornerLink {
height:100px;
width:200px;
opacity: 0.7;
position: absolute;
bottom: 0px;
left: 0px;
margin: 0;
padding: 0;
color: #ffffff;
background-color: cadetblue;
text-decoration: none;
text-align: center;
transform: translateX(0) translateY(100px) translateZ(0);
transition-duration:0.3s;
transition-property: transform;
}
.imageWrapper:hover .cornerLink {
transform: translateX(0) translateY(0) translateZ(0);
}
a{
color: #ffffff;
text-decoration: none;
text-align: center;
}
<body>
<main>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
</main>
</body>
Add overflow:hidden; to your .imageWrapper class. Here's working code:
.imageWrapper {
position: relative;
width: 200px;
height: 200px;
display: inline-block;
padding: 0px;
margin: 0px;
overflow:hidden;
}
.imageWrapper img {
display: block;
width: 200px;
height: 200px;
padding: 0px;
margin: 0px;
}
.imageWrapper .cornerLink {
height:100px;
width:200px;
opacity: 0.7;
position: absolute;
bottom: 0px;
left: 0px;
margin: 0;
padding: 0;
color: #ffffff;
background-color: cadetblue;
text-decoration: none;
text-align: center;
transform: translateX(0) translateY(100px) translateZ(0);
transition-duration:0.3s;
transition-property: transform;
}
.imageWrapper:hover .cornerLink {
transform: translateX(0) translateY(0) translateZ(0);
}
a{
color: #ffffff;
text-decoration: none;
text-align: center;
}
<body>
<main>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
</main>
</body>
Change this line transform: translateX(0) translateY(100px) translateZ(0); to transform: translateX(0) translateY(115px) translateZ(0);:
Add overflow:hidden to .imageWrapper to remove the space under images
.imageWrapper {
position: relative;
width: 200px;
height: 200px;
display: inline-block;
padding: 0px;
margin: 0px;
overflow: hidden; /* Hides links when off image */
}
.imageWrapper img {
display: block;
width: 200px;
height: 200px;
padding: 0px;
margin: 0px;
}
.imageWrapper .cornerLink {
height: 100px;
width: 200px;
opacity: 0.7;
position: absolute;
bottom: 0px;
left: 0px;
margin: 0;
padding: 0;
color: #ffffff;
background-color: cadetblue;
text-decoration: none;
text-align: center;
transform: translateX(0) translateY(100px) translateZ(0);
transition-duration: 0.3s;
transition-property: transform;
}
.imageWrapper:hover .cornerLink {
transform: translateX(0) translateY(0) translateZ(0);
}
a {
color: #ffffff;
text-decoration: none;
text-align: center;
}
<body>
<main>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
</main>
</body>
I want to give effect like this on image hover http://mahno.com.ua/en/architecture. Tried this but how to hide image on hover and display name .I have used CSS: On hover show and hide different div's at the same time? but having no luck.
EDIT: Want that effect in this code
<div class="content">
<div class="content-wrap">
<div>
<div>
<h1 class="title">Architecture</h1>
</div>
<!--section-title end-->
<div>
<div>
<span class="tim">Kube house</span>
<a href="#">
<img src="images/6151-fsdgsfg.gif">
</a>
<span class="tim">Kube house</span>
<a href="#">
<img src="images/6923-KUB%207.jpg">
</a>
</div>
<div>
<span class="tim">Kube house</span>
<a href="#">
<img src="images/7093-3.jpg">
</a>
<span class="tim">Kube house</span>
<a href="#">
<img src="images/1562-d.jpg">
</a>
</div>
<div>
<span class="tim">Kube house</span>
<a href="#">
<img src="images/5548-pddf.jpg">
</a>
<span class="tim">Kube house</span>
<a href="#">
<img src="images/1562-d.jpg">
</a>
</div>
<div>
<span class="tim">Kube house</span>
<a href="#">
<img src="images/1586-fdgsfgsdfggsdfgs.jpg">
</a>
<span class="tim">Kube house</span>
<a href="#">
<img src="images/1597-dogs.jpg">
</a>
<span class="tim">Kube house</span>
<a href="#">
<img src="images/6155-Untitled-3.gif">
</a>
</div>
<div>
<span class="tim">Kube house</span>
<a href="#">
<img src="images/3405-klink-mal.jpg">
</a>
<span class="tim">Kube house</span>
<a href="#">
<img src="images/6128-ghrt1.jpg">
</a>
<span class="tim">Kube house</span>
<a href="#">
<img src="images/1555-dsfsdfds.jpg">
</a>
</div>
</div> <!--product-list end-->
</div>
</div>
Sorry, for dirty code...
img {
display: block;
background-color: #fff;
transition: .2s;
}
.nav-ul:hover img {
opacity: 0;
}
a {
color: inherit;
text-decoration: none;
outline: none;
}
.list-unstyled {
padding: 0;
margin: 0;
list-style: none;
}
* {
box-sizing: border-box;
}
.nav-li {
position: relative;
}
.nav .tim {
opacity: 0;
position: absolute;
left: 6px;
bottom: 0;
transition: .5s;
}
.nav:hover .tim {
opacity: 1;
}
.nav .nav-ul {
padding: 0;
margin: 0;
list-style: none;
text-align: center;
}
.nav .nav-li {
display: inline-block;
font-size: 1em;
}
.nav .nav-li a {
position: relative;
display: block;
margin: 0 2px;
text-transform: uppercase;
overflow: hidden;
}
.nav .nav-li a:before {
box-sizing: border-box;
transform: translateX(100%);
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 2px;
border-bottom: 2px solid transparent;
border-left: 2px solid transparent;
}
.nav .nav-li a:after {
box-sizing: border-box;
transform: translateX(-100%);
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 2px;
border-top: 2px solid transparent;
border-right: 2px solid transparent;
}
.nav .nav-li a:hover {
color: inherit;
text-decoration: none;
}
.nav .nav-li a:hover:before {
transition: .2s transform linear, .2s height linear .2s;
transform: translateX(0);
height: 100%;
border-color: #1fbfac;
}
.nav .nav-li a:hover:after {
transition: .2s transform linear .4s, .2s height linear .6s;
transform: translateX(0);
height: 100%;
border-color: #1fbfac;
}
<div class="nav">
<div class="nav-ul">
<div class="nav-li">
<span class="tim">Kube house</span>
<a href="#">
<img src="http://beerhold.it/300/300">
</a>
</div>
</div>
<div class="nav-ul">
<div class="nav-li">
<span class="tim">Kube house</span>
<a href="#">
<img src="http://beerhold.it/300/300">
</a>
</div>
</div>
<div class="nav-ul">
<div class="nav-li">
<span class="tim">Kube house</span>
<a href="#">
<img src="http://beerhold.it/300/300">
</a>
</div>
</div>
</div>
To copy this effect you can inspect the element .no-touch .product-list .item a:hover on aforementioned site. There are span.title inside, and opacity for this element is changed from 0 to 1 on parent hovering. I can provide codepen for this, but after inspecting requested effect you will see that it is pretty self-explanatory.
For example:
.feature {
height:250px;
width:250px;
background:url('http://placehold.it/250x250');
position:relative;
}
.feature:hover {
background:red;
}
.feature:hover .title {
opacity: 1;
}
.title {
width:100%;
text-align:center;
position:absolute;
top:50%;
left:50%;
transform:translate(-50%, -50%);
display:block;
opacity:0;
}
<div class="feature">
<div class="title">Example Title</div>
</div>
Try this. It may help you.
HTML
<ul class="demo-3">
<li>
<figure>
<img src="https://lh6.ggpht.com/0d53JZiYmsBBhHv07OUeovHruEg0WvFdbhmy4iK1hyEifm6qV5dcEopPwq-Dz8eBWsxP=h900" alt="" width="100%"/>
<figcaption>
<h2>This is a cool title!</h2>
<p>A fish is any member of a paraphyletic group of organisms that consist of all gill-bearing aquatic craniate animals that lack limbs with digits.</p>
</figcaption>
</figure>
</li>
</ul>
CSS:
.demo-3 {
position:relative;
width:300px;
height:200px;
overflow:hidden;
float:left;
margin-right:20px
}
.demo-3 figure {
margin:0;
padding:0;
position:relative;
cursor:pointer;
margin-left:-50px
}
.demo-3 figure img {
display:block;
position:relative;
z-index:10;
margin:-15px 0
}
.demo-3 figure figcaption {
display:block;
position:absolute;
z-index:5;
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
box-sizing:border-box
}
.demo-3 figure h2 {
font-family:'Lato';
color:#fff;
font-size:20px;
text-align:left
}
.demo-3 figure p {
display:block;
font-family:'Lato';
font-size:12px;
line-height:18px;
margin:0;
color:#fff;
text-align:left
}
.demo-3 figure figcaption {
top:0;
left:0;
width:100%;
height:100%;
padding:29px 44px;
background-color:rgba(26,76,110,0.5);
text-align:center;
backface-visibility:hidden;
-webkit-transform:rotateY(-180deg);
-moz-transform:rotateY(-180deg);
transform:rotateY(-180deg);
-webkit-transition:all .5s;
-moz-transition:all .5s;
transition:all .5s
}
.demo-3 figure img {
backface-visibility:hidden;
-webkit-transition:all .5s;
-moz-transition:all .5s;
transition:all .5s
}
.demo-3 figure:hover img,figure.hover img {
-webkit-transform:rotateY(180deg);
-moz-transform:rotateY(180deg);
transform:rotateY(180deg)
}
.demo-3 figure:hover figcaption,figure.hover figcaption {
-webkit-transform:rotateY(0);
-moz-transform:rotateY(0);
transform:rotateY(0)
}
Run Code