So, I have a gallery that is laid out in a CSS grid. When I click on one of the items it opens info and images associated with that item. This info and images are also laid out in a grid.
My issue is that none of the transitions are working and I am not sure why and how to fix this.
// portfolio
$('.gallery .portfolio .portfolio-group a').click(function() {
var itemID = $(this).attr('href');
$('.gallery .portfolio').addClass('item_open');
$(itemID).addClass('item_open');
return false;
});
$('.close').click(function() {
$('.port, .gallery .portfolio').removeClass('item_open');
return false;
});
$(".gallery .portfolio .portfolio-group a").click(function() {
$('html, body').animate({
scrollTop: parseInt($("#top").offset().top)
}, 400);
});
*,
*:before,
*:after {
box-sizing: border-box;
}
body {
font-family: 'Lato', sans-serif;
font-weight: 300;
line-height: 1.5;
color: #333;
}
a {
color: #fff;
}
.row {
width: 100%;
max-width: 1170px;
margin: 0 auto;
padding: 0;
clear: both;
}
.row img {
max-width: 100%;
height: auto;
padding: 0;
margin: 0;
}
header {
background-color: #84b4b1;
color: #fff;
text-align: center;
padding: 30px 0 120px;
}
header h1 {
text-align: center;
text-transform: uppercase;
font-size: 65px;
font-weight: 400;
letter-spacing: 3px;
line-height: .8;
padding-top: 50px;
font-family: 'Montserrat', sans-serif;
}
header span {
text-transform: uppercase;
letter-spacing: 7px;
font-size: 25px;
line-height: 1;
}
header p {
padding-top: 30px;
}
.gallery {
padding: 40px 0 300px;
position: relative;
}
.clearfix:before,
.clearfix:after {
content: ".";
display: block;
overflow: hidden;
}
.clearfix:after {
clear: both;
}
.gallery .portfolio {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 5px;
}
.gallery .portfolio .portfolio-group {
overflow: hidden;
}
.gallery .portfolio .portfolio-group a {
display: block;
position: relative;
width: 85%;
height: 100%;
margin: 0;
padding: 0;
line-height: 0;
}
#media (min-width: 40em) {
.gallery .portfolio .portfolio-group a {
width: 100%;
}
}
#media (min-width: 64em) {
.gallery .portfolio .portfolio-group a {
width: 100%;
}
}
.gallery .portfolio .portfolio-group a:before {
position: absolute;
width: 32px;
height: 32px;
top: 40%;
left: 50%;
margin: -14px 0 0 -16px;
background: url(data:image/svg+xml;utf8,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%0A%3C%21--%20Generator%3A%20Adobe%20Illustrator%2017.1.0%2C%20SVG%20Export%20Plug-In%20.%20SVG%20Version%3A%206.00%20Build%200%29%20%20--%3E%0A%3C%21DOCTYPE%20svg%20PUBLIC%20%22-//W3C//DTD%20SVG%201.1//EN%22%20%22http%3A//www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd%22%3E%0A%3Csvg%20version%3D%221.1%22%0A%09%20id%3D%22svg2%22%20xmlns%3Adc%3D%22http%3A//purl.org/dc/elements/1.1/%22%20xmlns%3Acc%3D%22http%3A//creativecommons.org/ns%23%22%20xmlns%3Ardf%3D%22http%3A//www.w3.org/1999/02/22-rdf-syntax-ns%23%22%20xmlns%3Asvg%3D%22http%3A//www.w3.org/2000/svg%22%20xmlns%3Asodipodi%3D%22http%3A//sodipodi.sourceforge.net/DTD/sodipodi-0.dtd%22%20xmlns%3Ainkscape%3D%22http%3A//www.inkscape.org/namespaces/inkscape%22%20inkscape%3Aversion%3D%220.48.4%20r9939%22%20sodipodi%3Adocname%3D%22icon-fullscreen.svg%22%0A%09%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20xmlns%3Axlink%3D%22http%3A//www.w3.org/1999/xlink%22%20x%3D%220px%22%20y%3D%220px%22%20viewBox%3D%220%200%20960%20560%22%0A%09%20enable-background%3D%22new%200%200%20960%20560%22%20xml%3Aspace%3D%22preserve%22%3E%0A%3Csodipodi%3Anamedview%20%20borderopacity%3D%221%22%20pagecolor%3D%22%23ffffff%22%20bordercolor%3D%22%23666666%22%20objecttolerance%3D%2210%22%20gridtolerance%3D%2210%22%20guidetolerance%3D%2210%22%20showgrid%3D%22false%22%20fit-margin-top%3D%220%22%20fit-margin-left%3D%220%22%20inkscape%3Azoom%3D%227.375%22%20inkscape%3Acx%3D%22-5.1525424%22%20inkscape%3Acy%3D%2216%22%20id%3D%22namedview11%22%20inkscape%3Awindow-x%3D%22-8%22%20inkscape%3Awindow-y%3D%22-8%22%20fit-margin-right%3D%220%22%20inkscape%3Apageopacity%3D%220%22%20fit-margin-bottom%3D%220%22%20inkscape%3Awindow-width%3D%221366%22%20inkscape%3Awindow-height%3D%22706%22%20inkscape%3Awindow-maximized%3D%221%22%20inkscape%3Apageshadow%3D%222%22%20inkscape%3Acurrent-layer%3D%22svg2%22%3E%0A%09%3C/sodipodi%3Anamedview%3E%0A%3Cg%3E%0A%09%3Crect%20x%3D%22220%22%20y%3D%22260%22%20fill%3D%22%23FFFFFF%22%20width%3D%22536%22%20height%3D%2224%22/%3E%0A%3C/g%3E%0A%3Cg%3E%0A%09%3Crect%20x%3D%22476%22%20y%3D%224%22%20fill%3D%22%23FFFFFF%22%20width%3D%2224%22%20height%3D%22556%22/%3E%0A%3C/g%3E%0A%3C/svg%3E%0A) no-repeat;
content: '';
opacity: 0;
z-index: 1;
-webkit-transition: all, 0.3s, linear;
transition: all, 0.3s, linear;
}
.gallery .portfolio .portfolio-group a:hover:before {
top: 50%;
opacity: 1;
}
.gallery .portfolio .portfolio-group a:after {
position: absolute;
width: 100%;
top: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.3);
content: '';
opacity: 0;
transition: all, 0.3s, linear;
}
.gallery .portfolio .portfolio-group a:hover:after {
opacity: 1;
}
.gallery .portfolio-item-container {
display: grid;
grid-template-columns: repeat(1, 1fr);
grid-gap: 5px;
}
#media (min-width: 64em) {
.gallery .portfolio-item-container {
grid-template-columns: repeat(2, 1fr);
}
}
.port {
position: absolute;
width: 100%;
top: 0;
left: 0;
padding-top: 100px;
background: #ffffff;
background-color: #fafafa;
z-index: 103;
visibility: hidden;
transform: translateY(-100%);
border-bottom: 1px solid #d0d0d0;
transition: (all, 0.5s, ease-in-out);
}
.port img {
width: 100%;
}
.port h1 {
font-size: 35px;
line-height: 1;
padding: 0;
}
.port h1>* {
opacity: 0;
transition: (all, 0.5s, linear);
}
.port.item_open {
visibility: visible;
transform: translateY(0%);
transition: (all, 0.4s, ease-in-out);
}
.port.item_open>* {
opacity: 1;
transition-delay: 0.5s;
}
.close {
width: 21px;
height: 21px;
background: url(data:image/svg+xml;utf8,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%0A%3C%21--%20Generator%3A%20Adobe%20Illustrator%2017.1.0%2C%20SVG%20Export%20Plug-In%20.%20SVG%20Version%3A%206.00%20Build%200%29%20%20--%3E%0A%3C%21DOCTYPE%20svg%20PUBLIC%20%22-//W3C//DTD%20SVG%201.1//EN%22%20%22http%3A//www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd%22%3E%0A%3Csvg%20version%3D%221.1%22%0A%09%20id%3D%22svg2%22%20xmlns%3Adc%3D%22http%3A//purl.org/dc/elements/1.1/%22%20xmlns%3Acc%3D%22http%3A//creativecommons.org/ns%23%22%20xmlns%3Ardf%3D%22http%3A//www.w3.org/1999/02/22-rdf-syntax-ns%23%22%20xmlns%3Asvg%3D%22http%3A//www.w3.org/2000/svg%22%0A%09%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20xmlns%3Axlink%3D%22http%3A//www.w3.org/1999/xlink%22%20x%3D%220px%22%20y%3D%220px%22%20viewBox%3D%220%200%2021%2021%22%0A%09%20enable-background%3D%22new%200%200%2021%2021%22%20xml%3Aspace%3D%22preserve%22%3E%0A%3Cg%20id%3D%22layer1%22%20transform%3D%22translate%280%2C-1031.3622%29%22%3E%0A%09%3Cpath%20id%3D%22path2987%22%20fill%3D%22none%22%20stroke%3D%22%23000000%22%20d%3D%22M0%2C1031.4l21%2C21%22/%3E%0A%09%3Cpath%20id%3D%22path2989%22%20fill%3D%22none%22%20stroke%3D%22%23000000%22%20d%3D%22M21%2C1031.4l-21%2C21%22/%3E%0A%3C/g%3E%0A%3C/svg%3E%0A%0A) no-repeat;
position: absolute;
right: 50px;
margin-top: 50px;
opacity: 0;
z-index: 1004;
transition: (all, 0.1s, ease-in-out);
}
.item_open .close {
opacity: 1;
top: 0px;
transition: (all, 0.3s, ease-in-out);
}
<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">
</head>
<body translate="no" data-new-gr-c-s-check-loaded="8.896.0" data-gr-ext-installed="">
<link href='https://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Lato:300' rel='stylesheet' type='text/css'>
<header>
<h1>Portfolio Gallery</span>
</h1>
</header>
<div id="top"></div>
<!-- Projects -->
<section class="gallery clearfix">
<div class="row">
<div class="portfolio">
<a class="close" href="#"></a>
<div class="portfolio-group">
<a href="#item02">
<img src="https://cdn.dribbble.com/users/545884/screenshots/3981307/lorena2.png" alt="">
</a>
</div>
<!-- / div #1 -->
<div class="portfolio-group">
<a href="#item02">
<img src="https://cdn.dribbble.com/users/545884/screenshots/3892302/contact.png" alt="">
</a>
</div>
<!-- / div #2 -->
<div class="portfolio-group">
<a href="#item02">
<img src="https://cdn.dribbble.com/users/545884/screenshots/4154721/dive--001.png" alt="">
</a>
</div>
<!-- / div #3 -->
<div class="portfolio-group">
<a href="#item02">
<img src="https://cdn.dribbble.com/users/545884/screenshots/3695553/news.png" alt="">
</a>
</div>
<!-- / div #4 -->
<div class="portfolio-group">
<a href="#item02">
<img src="https://cdn.dribbble.com/users/545884/screenshots/3695553/news.png" alt="">
</a>
</div>
<!-- / div #5 -->
<div class="portfolio-group">
<a href="#item02">
<img src="https://cdn.dribbble.com/users/545884/screenshots/4360101/liberosis_--_12.png" alt="">
</a>
</div>
<!-- / div #6 -->
<div class="portfolio-group">
<a href="#item02">
<img src="https://cdn.dribbble.com/users/545884/screenshots/3148799/technical-book.jpg" alt="">
</a>
</div>
<!-- / div #7 -->
<div class="portfolio-group">
<a href="#item02">
<img src="https://cdn.dribbble.com/users/545884/screenshots/2883479/cover.jpg" alt="">
</a>
</div>
<!-- / div #8 -->
</div>
<!-- / .portfolio -->
</div>
<!-- / .row -->
<!-- Item 01-->
<div id="item01" class="port">
<div class="row">
<div class="description">
<h1>Item 01</h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus quis libero erat. Integer ac purus est. Proin erat mi, pulvinar ut magna eget, consectetur auctor turpis.
</div>
<!-- / .description -->
<img src="https://cdn.dribbble.com/users/545884/screenshots/3981307/lorena2.png" alt="">
</div>
<!-- / .row -->
</div>
<!-- / #item01-->
<!-- Item 02-->
<div id="item02" class="port">
<div class="row">
<div class="portfolio-item-container">
<div class="description">
<h1>Item 02</h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus quis libero erat. Integer ac purus est. Proin erat mi, pulvinar ut magna eget, consectetur auctor turpis.
</div>
<!-- / .description -->
<div class="portfolio-item">
<img src="dist/image/CAHQ-About-Us.jpg" alt="">
</div>
<div class="portfolio-item">
<img src="https://cdn.dribbble.com/users/545884/screenshots/3981307/lorena2.png" alt="">
</div>
<div class="portfolio-item">
<img src="https://cdn.dribbble.com/users/545884/screenshots/4360101/liberosis_--_12.png" alt="">
</div>
<div class="portfolio-item">
<img src="https://cdn.dribbble.com/users/545884/screenshots/4360101/liberosis_--_12.png" alt="">
</div>
<div class="portfolio-item">
<img src="https://cdn.dribbble.com/users/545884/screenshots/3981307/lorena2.png" alt="">
</div>
</div>
<!-- / .portfolio-item-container -->
</div>
<!-- / .row -->
</div>
<!-- / #item02-->
</section>
<!-- / Projects -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</body>
I realized I made a mistake in having the transition code in parentheses. With that fix, everything works and !
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>
:root {
--clr-primary: #0F052F;
--clr-secondary: #43D9B8;
--clr-light: #EEEEEE;
--fw-light: 300;
--fw-regular: 400;
--fw-medium: 500;
--fw-bold: 700;
}
* {
margin: 0;
box-sizing: border-box;
background-color: #FFFFFF;
}
body {
font-family: 'Poppins', sans-serif;
}
.wrapper {
width: 1440px;
margin: 0 auto;
padding: 0 100px;
}
/* Header - Navigation */
.desktop-nav {
display: flex;
justify-content: space-between;
align-items: center;
width: 1240px;
position: fixed;
z-index: 200;
top: 44px;
padding-right: 0;
}
.desktop-nav .menu-items {
display: flex;
list-style: none;
}
.desktop-nav .menu-items li {
margin: 0 27.5px;
}
.desktop-nav .menu-items li:nth-last-of-type(1) {
margin-right: 0;
}
.desktop-nav .menu-items li a {
text-decoration: none;
color: var(--clr-primary);
font-size: 16px;
font-weight: var(--fw-medium);
position: relative;
}
.desktop-nav .menu-items li a.active::after {
content: "";
position: absolute;
height: 3px;
width: 100%;
background-color: var(--clr-secondary);
left: 0;
bottom: -2px;
}
.desktop-nav .menu-items li a.btn {
color: white;
background-color: var(--clr-primary);
border-radius: 10px;
padding: 10px 23px;
}
/* BIA section */
.bia-container {
height: 100vh;
display: flex;
align-items: center;
justify-content: space-between;
}
.bia-container .left h1 {
font-size: 80px;
font-weight: var(--fw-bold);
margin: 60px 190px 18px 105px;
}
.bia-container .left p {
font-size: 18px;
font-weight: var(--fw-regular);
margin: 18px 195px 57px 105px;
}
.bia-container .left a.btn {
text-decoration: none;
color: rgb(0, 0, 0);
border-radius: 10px;
padding: 10px 23px;
border: 1px solid #43D9B8;
margin: 0 0 0 105px;
}
.bia-container .right {
padding-right: 105px;
}
/* Background header */
.bia-bg {
position: absolute;
z-index: -1;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Google Fonts-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght#300;400;500;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="wrapper">
<nav class="desktop-nav">
<div class="logo">
<a href="#">
<img src="Images/bia-logo.svg" alt="">
</div>
<ul class="menu-items">
<li>
Home
</li>
<li>
Services
</li>
<li>
Contact
</li>
<li>
Neem contact op
</li>
</ul>
</nav>
<!-- End of desktop navigation -->
<header class="bia-container">
<div class="left">
<h1>Make data work for you</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ut neque faucibus gravida viverra
tristique. Morbi quis commodo interdum id risus. Vitae hac viverra dui quis lobortis parturient
purus. Libero pharetra tortor.</p>
Neem contact op header
</div>
<div class="right">
<img src="Images/header-analytics.svg" alt="">
</div>
<img class="bia-bg" src="Images/header-background.svg" alt="">
<!-- End of header section -->
</header>
</div>
<script src="main.js"></script>
</body>
</html>
I have a problem. I have a background image that I want to display, however when I give the image a z-index of -1, it becomes invisible and isn't displayed in the background. Does anyone have an idea why this might be happening?
<div class="right">
<img src="Images/header-analytics.svg" alt="">
</div>
.bia-bg {
position: absolute;
z-index: -1;
}
The class and image I'm talking about is found on line 56 (HTML) and the class and image is on line 117 (CSS).
For your reference, the code can be found here: JSFiddle.
Any help would be much appreciated!
What it's supposed to look like:
Design
To put a background on a div or other element you only need to use this on CSS:
background-image: url("./your_image.png");
Getting like this
html
<div class="bg_img">
<!-- something -->
</div>
css
.bg_img{
background-image: url("Images/header-analytics.svg");
}
You have given absolutely everything a default white background.
This means that something with z index -1 cannot be seen at all because elements with default 0 z index cover it in white.
Try removing that blanket setting.
I'm trying to align my <div class="social-icons"> into bottom center of my sidebar.
Well icon is on bottom of the page, but on the left.
Screenshot of page: Page screenshot
My code:
#font-face {
font-family: 'FontAwesome';
src: url('../fonts/fontawesome-webfont.eot?v=4.2.0');
src: url('../fonts/fontawesome-webfont.eot?#iefix&v=4.2.0') format('embedded-opentype'), url('../fonts/fontawesome-webfont.woff?v=4.2.0') format('woff'), url('../fonts/fontawesome-webfont.ttf?v=4.2.0') format('truetype'), url('../fonts/fontawesome-webfont.svg?v=4.2.0#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}
/*---------------------------------------------------------
1. Reset
-------------------------------------------------------- */
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
vertical-align: baseline;
}
.blue {
color: #06C;
}
.green {
color: #090;
}
main {
display: block;
}
body {
line-height: 1;
}
ol,
ul {
list-style: none;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
html {
font-size: 100%;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
a:focus {
outline: none;
}
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
nav,
section {
display: block;
}
audio,
canvas,
video {
display: inline-block;
*display: inline;
*zoom: 1;
}
audio:not([controls]) {
display: none;
}
sub,
sup {
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -.5em;
}
sub {
bottom: -.25em;
}
img {
border: 0;
-ms-interpolation-mode: bicubic;
}
button,
input,
select,
textarea {
font-size: 100%;
margin: 0;
vertical-align: baseline;
*vertical-align: middle;
}
button,
input {
line-height: normal;
*overflow: visible;
}
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
cursor: pointer;
-webkit-appearance: button;
}
input[type="search"] {
-webkit-appearance: textfield;
}
input[type="search"]:-webkit-search-decoration {
-webkit-appearance: none;
}
textarea {
overflow: auto;
vertical-align: top;
}
/*---------------------------------------------------------
2. Basic Style
-------------------------------------------------------- */
body {
font-size: 14px;
line-height: 24px;
color: #777777;
font-family: 'Verdana';
overflow-x: hidden;
}
a {
color: #006699;
-webkit-transition: all 150ms ease-in-out;
-moz-transition: all 150ms ease-in-out;
-ms-transition: all 150ms ease-in-out;
-o-transition: all 150ms ease-in-out;
transition: all 150ms ease-in-out;
text-decoration: none !important;
}
a:hover {
color: #555555;
}
h1,
h2,
h3,
h4,
h5 {
color: #555555;
font-weight: bold;
}
::-webkit-input-placeholder {
color: #999999;
}
:-moz-placeholder {
/* Firefox 18- */
color: #999999;
}
::-moz-placeholder {
/* Firefox 19+ */
color: #999999;
}
:-ms-input-placeholder {
color: #999999;
}
.main-content,
.banner-bg {
float: right;
width: 87%;
}
#media screen and (max-width: 1290px) {
.main-content,
.banner-bg {
width: 70%;
}
}
#media screen and (max-width: 992px) {
.main-content,
.banner-bg {
width: 100%;
}
}
.content-wrapper {
padding: 0 80px;
}
#media screen and (max-width: 992px) {
.content-wrapper {
padding: 0 30px;
}
}
h4.widget-title {
font-size: 16px;
font-family: 'Verdana';
text-transform: uppercase;
margin-bottom: 40px;
}
hr {
position: relative;
outline: 0;
border: 0;
width: 100%;
height: 4px;
background: #dddddd;
margin-top: 40px;
margin-bottom: 0;
}
.page-section {
padding-top: 80px;
}
/*---------------------------------------------------------
3. Header
-------------------------------------------------------- */
.sidebar-menu {
float: left;
width: 13%;
height: 100%;
position: fixed;
background-color: #384553;
color: white;
overflow-y: hidden;
}
#media screen and (max-width: 1290px) {
.sidebar-menu {
overflow-y: scroll;
width: 30%;
}
}
.top-section {
padding: 40px;
}
.profile-image {
width: 150px;
height: 150px;
border: 4px solid white;
border-color: #505050;
-webkit-border-radius: 75px;
border-radius: 75px;
overflow: hidden;
margin-bottom: 20px;
margin: auto;
}
.profile-image img {
width: 100%;
}
h3.profile-title {
margin-bottom: 5px;
color: white;
font-size: 18px;
font-family: 'Verdana';
margin-top: 20px;
}
.main-navigation {
margin: 30px 0;
}
.main-navigation li {
display: block;
}
.main-navigation li a {
padding: 15px 40px;
display: block;
color: white;
font-size: 14px;
}
.main-navigation li a i {
margin-right: 15px;
font-size: 24px;
}
.main-navigation li a:hover {
background: #5b6878;
}
.main-navigation li a.active {
background: #495461;
}
.main-navigation li a.active:hover {
background: #495461;
}
.social-icons {
padding: 30px 40px;
position: fixed;
bottom: 0;
margin: auto;
text-align: center;
}
/* .social-icons li {
display: inline-block;
margin-right: 20px;
} */
.social-icons a {
font-size: 18px;
color: white;
}
.social-icons a:hover {
color: #282e35;
}
.responsive-header {
background: #5f6d7e;
text-align: center;
}
#media screen and (max-width: 992px) {
.responsive-header .main-navigation {
margin-top: 10px;
display: none;
}
}
#media screen and (max-width: 992px) {
.responsive-header p {
color: white;
}
}
#media screen and (max-width: 992px) {
.responsive-header .profile-image {
float: left;
width: 100px;
height: 100px;
-webkit-border-radius: 50px;
border-radius: 50px;
overflow: hidden;
margin-right: 30px;
}
.responsive-header .profile-content {
text-align: left;
margin-top: 30px;
overflow: hidden;
}
}
#media screen and (max-width: 992px) {
.top-section {
padding-bottom: 0;
}
}
#media screen and (max-width: 992px) {
.main-navigation a {
padding: 10px;
}
.main-navigation a.active {
background: #5f6d7e !important;
}
.main-navigation a:hover {
background: #5f6d7e !important;
}
}
.toggle-menu {
width: 100%;
display: block;
padding: 20px;
margin-top: 30px;
background: #6cc0f7;
color: white;
font-size: 18px;
}
.toggle-menu:hover {
color: white;
}
/*---------------------------------------------------------
4. Main Content
-------------------------------------------------------- */
/*------ banner ------ */
.banner-bg {
padding: 180px 80px;
position: relative;
background: url("../img/7.jpg");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
z-index: 2;
}
.banner-overlay {
position: absolute;
width: 100%;
height: 100%;
background: rgba(95, 109, 126, 0.4);
top: 0;
left: 0;
z-index: 3;
}
.welcome-text {
position: relative;
z-index: 4;
}
.welcome-text h2 {
font-size: 42px;
font-family: 'Verdana';
color: white;
margin-bottom: 30px;
}
.welcome-text h5 {
font-size: 22px;
color: white;
}
/*------ about us ------ */
.about-image {
overflow: hidden;
border: 4px solid #dddddd;
margin-bottom: 40px;
}
.about-image img {
width: 100%;
display: block;
}
/*------ projects ------ */
.projects-holder {
margin-right: 0;
margin-left: 0;
margin-top: 40px;
}
.projects-holder .col-md-4,
.projects-holder .col-md-4 {
padding-right: 1px;
padding-left: 1px;
}
.project-item {
width: 100%;
margin-bottom: 2px;
overflow: hidden;
position: relative;
}
.project-item img {
width: 100%;
display: block;
}
.project-item:hover .project-hover {
top: 0;
opacity: 1;
visibility: visible;
}
.project-hover {
position: absolute;
width: 100%;
height: 100%;
top: 40px;
left: 0;
background: rgba(0, 0, 0, 0.9);
opacity: 0;
visibility: 0;
-webkit-transition: all 200ms linear;
-moz-transition: all 200ms linear;
-ms-transition: all 200ms linear;
-o-transition: all 200ms linear;
transition: all 200ms linear;
}
.project-hover .inside {
position: absolute;
width: 100%;
left: 0;
bottom: 0;
padding: 30px;
}
.project-hover h5 {
font-size: 16px;
margin-bottom: 15px;
}
.project-hover h5 a {
color: white;
}
.project-hover p {
color: white;
font-size: 13px;
line-height: 20px;
}
/*------ contact ------ */
.contact-form {
margin-top: 40px;
}
.contact-form input,
.contact-form textarea {
width: 100%;
outline: 0;
border: 1px solid #aaaaaa;
padding: 12px;
color: #999999;
margin-bottom: 30px;
}
.contact-form input:focus,
.contact-form textarea:focus {
outline: 0;
}
.contact-form .button {
width: auto;
background: #5f6d7e;
color: white;
text-transform: uppercase;
border: 0;
}
/*---------------------------------------------------------
5. Footer
-------------------------------------------------------- */
#footer p.copyright-text {
margin: 40px 0;
font-size: 13px;
}
#footer p.copyright-text a {
color: #5f6d7e;
}
#footer p.copyright-text a:hover {
color: #6cc0f7;
}
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Autoservis Jiří Baloun</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/font-awesome.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/styles.css">
<script src="js/vendor/modernizr-2.6.2.min.js"></script>
</head>
<body>
<!-- SIDEBAR -->
<div class="sidebar-menu hidden-xs hidden-sm">
<div class="top-section">
<div class="profile-image">
<img src="img/profile.jpg">
</div>
<h3 class="profile-title" align="center">Autoservis Jiří Baloun</h3>
<!-- <p class="profile-description">Digital Photography</p> -->
</div>
<!-- top-section -->
<div class="main-navigation">
<ul class="navigation">
<li><i class="fa fa-globe"></i>O nás</li>
<li><i class="fa fa-pencil"></i>Služby</li>
<li><i class="fa fa-camera-retro"></i>Galerie</li>
<li><i class="fa fa-link"></i>Kontakt</li>
</ul>
</div>
<!-- .main-navigation -->
<div class="social-icons">
<i class="fa fa-facebook-square" style="font-size:36px"></i>
</div>
<!-- .social-icons -->
</div>
<!-- .sidebar-menu -->
<div class="banner-bg" id="top">
<div class="banner-overlay"></div>
<div class="welcome-text">
<h2>Autoservis Jiří Baloun</h2>
<h5>Servis osobních vozidel</h5>
</div>
</div>
<!-- MAIN CONTENT -->
<div class="main-content">
<div class="fluid-container">
<div class="content-wrapper">
<!-- ABOUT -->
<div class="page-section" id="about">
<div class="row">
<div class="col-md-12">
<h4 class="widget-title">O nás</h4>
<!-- <div class="about-image">
<img src="img/8.jpg" alt="about me">
</div> -->
<p></p>
<hr>
</div>
</div>
<!-- #about -->
</div>
<!-- PROJECTS -->
<div class="page-section" id="projects">
<div class="row">
<div class="col-md-12">
<h4 class="widget-title">Náhled naší práce</h4>
<p>Duis sed odio sit amet nibh vulputate cursus a sit amet mauris. Morbi accumsan ipsum velit. Nam nec tellus a odio tincidunt auctor a ornare odio. Maecenas et lorem molestie, maximus justo dignissim, cursus nisl. Nullam at ante quis ex pharetra
pulvinar quis id dolor. Integer lorem odio, euismod ut sem sit amet, imperdiet condimentum diam.</p>
</div>
</div>
<div class="row projects-holder">
<div class="col-md-4 col-sm-6">
<div class="project-item">
<img src="img/1.jpg" alt="">
<div class="project-hover">
<div class="inside">
<h5>Pellentesque porta ligula</h5>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam cursus</p>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6">
<div class="project-item">
<img src="img/2.jpg" alt="">
<div class="project-hover">
<div class="inside">
<h5>Pellentesque porta ligula</h5>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam cursus</p>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6">
<div class="project-item">
<img src="img/3.jpg" alt="">
<div class="project-hover">
<div class="inside">
<h5>Pellentesque porta ligula</h5>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam cursus.</p>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6">
<div class="project-item">
<img src="img/4.jpg" alt="">
<div class="project-hover">
<div class="inside">
<h5>Pellentesque porta ligula</h5>
<p>Quisque mattis sit amet dolor eu scelerisque. Vivamus bibendum massa et nisl tempus commodo.</p>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6">
<div class="project-item">
<img src="img/5.jpg" alt="">
<div class="project-hover">
<div class="inside">
<h5>Pellentesque porta ligula</h5>
<p>Quisque mattis sit amet dolor eu scelerisque. Vivamus bibendum massa et nisl tempus commodo.</p>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6">
<div class="project-item">
<img src="img/6.jpg" alt="">
<div class="project-hover">
<div class="inside">
<h5>Pellentesque porta ligula</h5>
<p>Quisque mattis sit amet dolor eu scelerisque. Vivamus bibendum massa et nisl tempus commodo.</p>
</div>
</div>
</div>
</div>
</div>
<!-- .projects-holder -->
</div>
<hr>
<!-- CONTACT -->
<div class="page-section" id="contact">
<div class="row">
<div class="col-md-12">
<h4 class="widget-title">KONTAKTUJTE NÁS</h4>
<p>Máte-li jakékoliv dotazy ohledně nabízených služeb, cen a podobně, neváhejte nás kontaktovat telefonicky nebo prostřednictvím tohoto formuláře.</p>
</div>
</div>
<div class="row">
<form action="#" method="post" class="contact-form">
<fieldset class="col-md-4 col-sm-6">
<input type="text" id="your-name" placeholder="Vaše jméno">
</fieldset>
<fieldset class="col-md-4 col-sm-6">
<input type="email" id="email" placeholder="Váš email">
</fieldset>
<fieldset class="col-md-4 col-sm-12">
<input type="text" id="your-subject" placeholder="Předmět zprávy">
</fieldset>
<fieldset class="col-md-12 col-sm-12">
<textarea name="message" id="message" cols="30" rows="6" placeholder="Napište nám"></textarea>
</fieldset>
<fieldset class="col-md-12 col-sm-12">
<input type="submit" class="button big default" value="Odeslat">
</fieldset>
</form>
</div>
<!-- .contact-form -->
</div>
<hr>
<div class="row" id="footer">
<div class="col-md-12 text-center">
<p class="copyright-text">Copyright © 2021 Autoservis Jiří Baloun</p>
</div>
</div>
</div>
</div>
</div>
<script src="js/vendor/jquery-1.10.2.min.js"></script>
<script src="js/min/plugins.min.js"></script>
<script src="js/min/main.min.js"></script>
</body>
</html>
Use this:
.social-icons {
padding: 30px 40px;
position: absolute;
bottom: 0;
margin: auto;
text-align: center;
width: 100%;
left: 0;
right: 0;
}
If you give width to your social-icons you can align your items to center.
like below;
.social-icons {
padding: 30px 40px;
position: fixed;
bottom: 0;
margin: auto;
text-align: center;
width: 100%;
}
I set the top navigation bar as being sticky on top, but it's acting weird in some places.
Here's the fiddle link https://jsfiddle.net/benjaminana77/pugek2f8/30/ and I reproduced code below.
I'm having problems in three places
In the hero image section, top nav background is incorrectly being transparent. I set the background color as white, not transparent.
The top nav bar incorrectly shows BEHIND a slider, not above the slider.
When you hover over an item in the grid layout, the item shows above the top nav bar.
normal state:
when you hover over an image:
Many thanks in advance!
HTML:
<div class="boxA">
<div class="box1">
<div class="site">
<img src="img/logo.png">
</div>
</div>
<div class="box2">
<nav class="menu">
<ul>
<li>menu1</li>
<li>menu2</li>
<li>menu3</li>
<li>menu4</li>
</ul>
</nav>
</div>
</div>
<div class="body-part">
<section class="conA">
<div id="container">
<div id="heroText">
<p>Lorem ipsum 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 exercit</p>
<div id="text"></div>
</div>
<div id="images"></div>
</div>
</section>
<ul class="slider" style="padding:0px !important;">
<li><img src="img/sample.png">
<div class="caption1">caption 1</div>
</li>
<li> <img src="img/Group 3.png">
<div class="caption2"></div>
<div class="caption3">caption 2</div>
<div class="caption5">caption 3</div>
<div class="caption4">caption 4</div>
</li>
</ul>
<section id="conD">
<div class="container">
<div class="grid menu-content" id="menu1-content">
<article>
<a href="#">
<div class="photo" style="background-image: url(https://www.gravatar.com/avatar/a235706e3d81b614acaec3368edfea4b?s=96&d=identicon&r=PG);"></div>
<div class="text">
<h3>Title </h3>
<p>Lorem ipsum dolor </p>
</div>
</a>
</article>
<article>
<a href="#">
<div class="photo" style="background-image: url(img/sample.jpg);"></div>
<div class="text">
<h3>Headingg</h3>
<p>Lorem ipsum dolor </p>
</div>
</a>
</article>
<article>
<a href="#">
<div class="photo" style="background-image: url(img/sample.jpg);"></div>
<div class="text">
<h3>Headingg</h3>
<p>Lorem ipsum dolor </p>
</div>
</a>
</article>
</div>
</div>
</section>
CSS:
.boxA:after {
content:"";
display: block;
clear: both;
}
.boxA {
height: 90px;
position: fixed;
border-bottom: 1px solid #E0DCDC;
top: 0;
width: 100%;
background-color: white;
max-width: 1440px;
}
.boxA img {
position: absolute;
top: 50%;
left: 3%;
transform: translate(0, -50%);
}
.box2 ul {
position: absolute;
top: 50%;
transform: translate(0, -50%);
right: 10px;
}
.box1 {
float: left;
width: auto;
}
.box2 {
float: right;
width: auto;
}
.box2 ul {
margin: 0;
padding: 0;
list-style: none;
}
.box2 li a {
display: block;
padding: 0px 50px;
color: inherit;
text-decoration: none;
font-size: 12px;
}
.box2 li a:hover {
text-decoration: underline;
}
.box2 ul:after {
content: "";
display: block;
clear: both;
}
.box2 li {
float: left;
width: auto;
font-family: 'Gotham';
letter-spacing: 2.5px;
}
.box1 img {
position: absolute;
width: 20%;
height: auto;
}
#top-logo {
margin-top: 40px;
}
#top-logo img {
display: block;
margin-left: auto;
margin-right: auto;
width: 20%;
height: auto;
}
body {
font-family: gotham;
margin: 0px !important;
color: #827F88;
letter-spacing: 0.4px;
line-height: 1.9;
}
.conA {
height: 100vh;
display: flex;
position: relative;
}
.conA #container {
margin: 0;
display: flex;
align-items: flex-start;
position: absolute;
top: 50%;
left: 10%;
transform: translate(0%, -50%);
}
#heroText {
font-size: 37px;
color: #56525E;
line-height: 1 !important;
}
.conA #heroText {
height: 400px;
padding-top: 100px;
}
#conD ul {
margin: 0 0 30px -30px;
padding: 0;
list-style: none;
}
#conD li {
padding: 35px;
display: block;
text-decoration: none;
font-size: 15.5px;
letter-spacing: 2px;
color: inherit;
}
#conD li {
float: left;
width: auto;
}
#conD ul:after {
content:"";
display: block;
clear: both;
}
#conD .menu {
margin-bottom: 20px
}
.grid {
display: grid;
justify-content: start;
margin-top: -20px;
}
.grid .photo {
width: 100%;
background-size: contain;
background-position: center;
}
.grid .photo:after {
content: "";
display: block;
padding-bottom: 100%;
}
.grid a {
display: block;
text-decoration: none;
color: inherit;
}
.grid a:hover {
opacity: 0.8;
}
JQUERY:
$(document).ready(function(){
$('.slider').bxSlider({
auto: true,
pause: 3000,
mode: 'fade',
speed: 1200,
pager: false
});
});
(function ($) {
$(document).ready(function(){
// hide .navbar first
$(".boxA").hide();
// fade in .navbar
$(function () {
$(window).scroll(function () {
// set distance user needs to scroll before we start fadeIn
if ($(this).scrollTop() > 50) {
$('.boxA').fadeIn();
$('#top-logo').fadeOut();
} else {
$('.boxA').fadeOut();
$('#top-logo').fadeIn();
}
});
});
});
}(jQuery));
Add z-index:2 on .boxA
.boxA {
height: 90px;
position: fixed;
border-bottom: 1px solid #E0DCDC;
top: 0;
width: 100%;
background-color: white;
max-width: 1440px;
z-index: 2;
}
.body-part{
position: relative;
z-index: 1;
}
https://jsfiddle.net/lalji1051/24rm0yvt/
updated link - https://jsfiddle.net/lalji1051/24rm0yvt/3/
I'm trying to show a description when hovering over an image. I've already done it in a less than desirable way, using image sprites and hovers here: I want it to look exactly like how I have it, but using real text instead of an image.
I've tried a few different things but I can't seem to figure out how to do it. I'm trying to do it using HTML and CSS only, but I'm not sure if that's possible.
Feel free to poke around in my code, I'll paste what I think is relavent here.
HTML
div#projectlist {
width: 770px;
margin: 0 auto;
margin-top: 20px;
margin-bottom: 40px;
}
div#buzzbutton {
display: block;
float: left;
margin: 2px;
background: url(content/assets/thumbnails/design/buzz_sprite.jpg) 0 0px no-repeat;
width: 150px;
height: 150px;
}
div#buzzbutton:hover {
background: url(content/assets/thumbnails/design/buzz_sprite.jpg);
width: 150px;
height: 150px;
background-position: 0 -150px;
}
div#slinksterbutton {
display: block;
float: left;
background: url(content/assets/thumbnails/design/slinkster_sprite.jpg) 0 0px no-repeat;
width: 150px;
height: 150px;
margin: 2px;
}
div#slinksterbutton:hover {
background: url(content/assets/thumbnails/design/slinkster_sprite.jpg);
width: 150px;
height: 150px;
background-position: 0 -150px;
}
<div id="projectlist">
<div id="buzzbutton">
<img src="content/assets/thumbnails/transparent_150x150.png" alt="" />
</div>
<div id="slinksterbutton">
<img src="content/assets/thumbnails/transparent_150x150.png" alt="" />
</div>
</div>
It's simple. Wrap the image and the "appear on hover" description in a div with the same dimensions of the image. Then, with some CSS, order the description to appear while hovering that div.
/* quick reset */
* {
margin: 0;
padding: 0;
border: 0;
}
/* relevant styles */
.img__wrap {
position: relative;
height: 200px;
width: 257px;
}
.img__description {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(29, 106, 154, 0.72);
color: #fff;
visibility: hidden;
opacity: 0;
/* transition effect. not necessary */
transition: opacity .2s, visibility .2s;
}
.img__wrap:hover .img__description {
visibility: visible;
opacity: 1;
}
<div class="img__wrap">
<img class="img__img" src="http://placehold.it/257x200.jpg" />
<p class="img__description">This image looks super neat.</p>
</div>
A nice fiddle: https://jsfiddle.net/govdqd8y/
EDIT:
There's another option if you don't want to explicitly set the height of the <img> on the wrapping <div>, and that is simply setting the <div>'s display to inline-block. (Keep in mind, though, that it won't look good if the image fails to load.)
If you choose this option, you'll notice that there'll be a slight spacing between the <img> and the bottom of the wrapping <div>. That's because of the <img>'s default vertical-align value of baseline. If you set it to bottom it will disappear.
Here's a fiddle using this option: https://jsfiddle.net/joplomacedo/5cL31o0g/
In your HTML, try and put the text that you want to come up in the title part of the code:
<a href="buzz.html" title="buzz hover text">
You can also do the same for the alt text of your image.
You can also use the title attribute in your image tag
<img src="content/assets/thumbnails/transparent_150x150.png" alt="" title="hover text" />
This is what I use to make the text appear on hover:
* {
box-sizing: border-box
}
div {
position: relative;
top: 0px;
left: 0px;
width: 400px;
height: 400px;
border-radius: 50%;
overflow: hidden;
text-align: center
}
img {
width: 400px;
height: 400px;
position: absolute;
border-radius: 50%
}
img:hover {
opacity: 0;
transition:opacity 2s;
}
heading {
line-height: 40px;
font-weight: bold;
font-family: "Trebuchet MS";
text-align: center;
position: absolute;
display: block
}
div p {
z-index: -1;
width: 420px;
line-height: 20px;
display: inline-block;
padding: 200px 0px;
vertical-align: middle;
font-family: "Trebuchet MS";
height: 450px
}
<div>
<img src="https://68.media.tumblr.com/20b34e8d12d4230f9b362d7feb148c57/tumblr_oiwytz4dh41tf8vylo1_1280.png">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing <br>elit. Reiciendis temporibus iure dolores aspernatur excepturi <br> corporis nihil in suscipit, repudiandae. Totam.
</p>
</div>
.container {
position: relative;
width: 50%;
}
.image {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: #008CBA;
}
.container:hover .overlay {
opacity: 1;
}
.text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}
<!DOCTYPE html>
<html>
<head></head>
<body>
<div class="container">
<img src="http://lorempixel.com/500/500/" alt="Avatar" class="image">
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
</body>
</html>
Reference Link W3schools with multiple styles
HTML
<img id="close" className="fa fa-close" src="" alt="" title="Close Me" />
CSS
#close[title]:hover:after {
color: red;
content: attr(title);
position: absolute;
left: 50px;
}
I saw a lot of people use an image tag. I prefer to use a background image because I can manipulate it. For example, I can:
Add smoother transitions
save time not having to crop images by using the "background-size: cover;" property.
The HTML/CSS:
.overlay-box {
background-color: #f5f5f5;
height: 100%;
background-repeat: no-repeat;
background-size: cover;
}
.overlay-box:hover .desc,
.overlay-box:focus .desc {
opacity: 1;
}
/* opacity 0.01 for accessibility */
/* adjust the styles like height,padding to match your design*/
.overlay-box .desc {
opacity: 0.01;
min-height: 355px;
font-size: 1rem;
height: 100%;
padding: 30px 25px 20px;
transition: all 0.3s ease;
background: rgba(0, 0, 0, 0.7);
color: #fff;
}
<div class="overlay-box" style="background-image: url('https://via.placeholder.com/768x768');">
<div class="desc">
<p>Place your text here</p>
<ul>
<li>lorem ipsum dolor</li>
<li>lorem lipsum</li>
<li>lorem</li>
</ul>
</div>
</div>
<!DOCTYPE html><html lang='en' class=''>
<head><script src='//production-assets.codepen.io/assets/editor/live/console_runner-079c09a0e3b9ff743e39ee2d5637b9216b3545af0de366d4b9aad9dc87e26bfd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/events_runner-73716630c22bbc8cff4bd0f07b135f00a0bdc5d14629260c3ec49e5606f98fdd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/css_live_reload_init-2c0dc5167d60a5af3ee189d570b1835129687ea2a61bee3513dee3a50c115a77.js'></script><meta charset='UTF-8'><meta name="robots" content="noindex"><link rel="shortcut icon" type="image/x-icon" href="//production-assets.codepen.io/assets/favicon/favicon-8ea04875e70c4b0bb41da869e81236e54394d63638a1ef12fa558a4a835f1164.ico" /><link rel="mask-icon" type="" href="//production-assets.codepen.io/assets/favicon/logo-pin-f2d2b6d2c61838f7e76325261b7195c27224080bc099486ddd6dccb469b8e8e6.svg" color="#111" /><link rel="canonical" href="https://codepen.io/nelsonleite/pen/RaGwba?depth=everything&order=popularity&page=4&q=product&show_forks=false" />
<link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>
<link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'>
<style class="cp-pen-styles">.product-description {
transform: translate3d(0, 0, 0);
transform-style: preserve-3d;
perspective: 1000;
backface-visibility: hidden;
}
body {
color: #212121;
}
.container {
padding-top: 25px;
padding-bottom: 25px;
}
img {
max-width: 100%;
}
hr {
border-color: #e5e5e5;
margin: 15px 0;
}
.secondary-text {
color: #b6b6b6;
}
.list-inline {
margin: 0;
}
.list-inline li {
padding: 0;
}
.card-wrapper {
position: relative;
width: 100%;
height: 390px;
border: 1px solid #e5e5e5;
border-bottom-width: 2px;
overflow: hidden;
margin-bottom: 30px;
}
.card-wrapper:after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
transition: opacity 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.card-wrapper:hover:after {
opacity: 1;
}
.card-wrapper:hover .image-holder:before {
opacity: .75;
}
.card-wrapper:hover .image-holder:after {
opacity: 1;
transform: translate(-50%, -50%);
}
.card-wrapper:hover .image-holder--original {
transform: translateY(-15px);
}
.card-wrapper:hover .product-description {
height: 205px;
}
#media (min-width: 768px) {
.card-wrapper:hover .product-description {
height: 185px;
}
}
.image-holder {
display: block;
position: relative;
width: 100%;
height: 310px;
background-color: #ffffff;
z-index: 1;
}
#media (min-width: 768px) {
.image-holder {
height: 325px;
}
}
.image-holder:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #4CAF50;
opacity: 0;
z-index: 5;
transition: opacity 0.6s;
}
.image-holder:after {
content: '+';
font-family: 'Raleway', sans-serif;
font-size: 70px;
color: #4CAF50;
text-align: center;
position: absolute;
top: 92.5px;
left: 50%;
width: 75px;
height: 75px;
line-height: 75px;
background-color: #ffffff;
opacity: 0;
border-radius: 50%;
z-index: 10;
transform: translate(-50%, 100%);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
transition: all 0.4s ease-out;
}
#media (min-width: 768px) {
.image-holder:after {
top: 107.5px;
}
}
.image-holder .image-holder__link {
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 15;
}
.image-holder .image-holder--original {
transition: transform 0.8s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.image-liquid {
width: 100%;
height: 325px;
background-size: cover;
background-position: center center;
}
.product-description {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 80px;
padding: 10px 15px;
overflow: hidden;
background-color: #fafafa;
border-top: 1px solid #e5e5e5;
transition: height 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
z-index: 2;
}
#media (min-width: 768px) {
.product-description {
height: 65px;
}
}
.product-description p {
margin: 0 0 5px;
}
.product-description .product-description__title {
font-family: 'Raleway', sans-serif;
position: relative;
white-space: nowrap;
overflow: hidden;
margin: 0;
font-size: 18px;
line-height: 1.25;
}
.product-description .product-description__title:after {
content: '';
width: 60px;
height: 100%;
position: absolute;
top: 0;
right: 0;
background: linear-gradient(to right, rgba(255, 255, 255, 0), #fafafa);
}
.product-description .product-description__title a {
text-decoration: none;
color: inherit;
}
.product-description .product-description__category {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.product-description .product-description__price {
color: #4CAF50;
text-align: left;
font-weight: bold;
letter-spacing: 0.06em;
}
#media (min-width: 768px) {
.product-description .product-description__price {
text-align: right;
}
}
.product-description .sizes-wrapper {
margin-bottom: 15px;
}
.product-description .color-list {
font-size: 0;
}
.product-description .color-list__item {
width: 25px;
height: 10px;
position: relative;
z-index: 1;
transition: all .2s;
}
.product-description .color-list__item:hover {
width: 40px;
}
.product-description .color-list__item--red {
background-color: #F44336;
}
.product-description .color-list__item--blue {
background-color: #448AFF;
}
.product-description .color-list__item--green {
background-color: #CDDC39;
}
.product-description .color-list__item--orange {
background-color: #FF9800;
}
.product-description .color-list__item--purple {
background-color: #673AB7;
}
</style></head><body>
<!--
Inspired in this dribbble
https://dribbble.com/shots/986548-Product-Catalog
-->
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-4">
<article class="card-wrapper">
<div class="image-holder">
<div class="image-liquid image-holder--original" style="background-image: url('https://upload.wikimedia.org/wikipedia/commons/2/24/Blue_Tshirt.jpg')">
</div>
</div>
<div class="product-description">
<!-- title -->
<h1 class="product-description__title">
<a href="#">
Adidas Originals
</a>
</h1>
<!-- category and price -->
<div class="row">
<div class="col-xs-12 col-sm-8 product-description__category secondary-text">
Men's running shirt
</div>
<div class="col-xs-12 col-sm-4 product-description__price">
€ 499
</div>
</div>
<!-- divider -->
<hr />
<!-- sizes -->
<div class="sizes-wrapper">
<b>Sizes</b>
<br />
<span class="secondary-text text-uppercase">
<ul class="list-inline">
<li>xs,</li>
<li>s,</li>
<li>sm,</li>
<li>m,</li>
<li>l,</li>
<li>xl,</li>
<li>xxl</li>
</ul>
</span>
</div>
<!-- colors -->
<div class="color-wrapper">
<b>Colors</b>
<br />
<ul class="list-inline color-list">
<li class="color-list__item color-list__item--red"></li>
<li class="color-list__item color-list__item--blue"></li>
<li class="color-list__item color-list__item--green"></li>
<li class="color-list__item color-list__item--orange"></li>
<li class="color-list__item color-list__item--purple"></li>
</ul>
</div>
</div>
</article>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<article class="card-wrapper">
<div class="image-holder">
<div class="image-liquid image-holder--original" style="background-image: url('https://upload.wikimedia.org/wikipedia/commons/thumb/7/75/Jeans_BW_2_(3213391837).jpg/543px-Jeans_BW_2_(3213391837).jpg')">
</div>
</div>
<div class="product-description">
<!-- title -->
<h1 class="product-description__title">
<a href="#">
Adidas Originals
</a>
</h1>
<!-- category and price -->
<div class="row">
<div class="col-sm-8 product-description__category secondary-text">
Men's running shirt
</div>
<div class="col-sm-4 product-description__price text-right">
€ 499
</div>
</div>
<!-- divider -->
<hr />
<!-- sizes -->
<div class="sizes-wrapper">
<b>Sizes</b>
<br />
<span class="secondary-text text-uppercase">
<ul class="list-inline">
<li>xs,</li>
<li>s,</li>
<li>sm,</li>
<li>m,</li>
<li>l,</li>
<li>xl,</li>
<li>xxl</li>
</ul>
</span>
</div>
<!-- colors -->
<div class="color-wrapper">
<b>Colors</b>
<br />
<ul class="list-inline color-list">
<li class="color-list__item color-list__item--red"></li>
<li class="color-list__item color-list__item--blue"></li>
<li class="color-list__item color-list__item--green"></li>
<li class="color-list__item color-list__item--orange"></li>
<li class="color-list__item color-list__item--purple"></li>
</ul>
</div>
</div>
</article>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<article class="card-wrapper">
<div class="image-holder">
<div class="image-liquid image-holder--original" style="background-image: url('https://upload.wikimedia.org/wikipedia/commons/b/b8/Columbia_Sportswear_Jacket.jpg')">
</div>
</div>
<div class="product-description">
<!-- title -->
<h1 class="product-description__title">
<a href="#">
Adidas Originals
</a>
</h1>
<!-- category and price -->
<div class="row">
<div class="col-sm-8 product-description__category secondary-text">
Men's running shirt
</div>
<div class="col-sm-4 product-description__price text-right">
€ 499
</div>
</div>
<!-- divider -->
<hr />
<!-- sizes -->
<div class="sizes-wrapper">
<b>Sizes</b>
<br />
<span class="secondary-text text-uppercase">
<ul class="list-inline">
<li>xs,</li>
<li>s,</li>
<li>sm,</li>
<li>m,</li>
<li>l,</li>
<li>xl,</li>
<li>xxl</li>
</ul>
</span>
</div>
<!-- colors -->
<div class="color-wrapper">
<b>Colors</b>
<br />
<ul class="list-inline color-list">
<li class="color-list__item color-list__item--red"></li>
<li class="color-list__item color-list__item--blue"></li>
<li class="color-list__item color-list__item--green"></li>
<li class="color-list__item color-list__item--orange"></li>
<li class="color-list__item color-list__item--purple"></li>
</ul>
</div>
</div>
</article>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<article class="card-wrapper">
<div class="image-holder">
<div class="image-liquid image-holder--original" style="background-image: url('http://www.publicdomainpictures.net/pictures/20000/nahled/red-shoes-isolated.jpg')">
</div>
</div>
<div class="product-description">
<!-- title -->
<h1 class="product-description__title">
<a href="#">
Adidas Originals
</a>
</h1>
<!-- category and price -->
<div class="row">
<div class="col-sm-8 product-description__category secondary-text">
Men's running shirt
</div>
<div class="col-sm-4 product-description__price text-right">
€ 499
</div>
</div>
<!-- divider -->
<hr />
<!-- sizes -->
<div class="sizes-wrapper">
<b>Sizes</b>
<br />
<span class="secondary-text text-uppercase">
<ul class="list-inline">
<li>xs,</li>
<li>s,</li>
<li>sm,</li>
<li>m,</li>
<li>l,</li>
<li>xl,</li>
<li>xxl</li>
</ul>
</span>
</div>
<!-- colors -->
<div class="color-wrapper">
<b>Colors</b>
<br />
<ul class="list-inline color-list">
<li class="color-list__item color-list__item--red"></li>
<li class="color-list__item color-list__item--blue"></li>
<li class="color-list__item color-list__item--green"></li>
<li class="color-list__item color-list__item--orange"></li>
<li class="color-list__item color-list__item--purple"></li>
</ul>
</div>
</div>
</article>
</div>
</div>
</div>
</body></html>
The sample is made
<html>
<head>
<style>
.hide {
display: none;
}
.myDIV:hover + .hide {
display: block;
color: red;
}
</style>
</head>
<body>
<h2>Display an Element on Hover</h2>
<div class="myDIV">Hover over me.</div>
<div class="hide">I am shown when someone hovers over the div above.</div>
</body>
</html>
For accessibility reasons, you should use the correct semantic tags. Use a figure as a container and include the text to the image as figcaption.
Apply position: absolute to the container and then position: absolute to the figcaption.
Simply hide the figcaption with display: block and make it visible again by using :hover on the wrapping figure element.
figure {
position: relative;
}
figcaption {
position: absolute;
inset: 2px;
display: none;
}
figure:hover figcaption {
display: flex;
}
/* for visualization only */
figure {
display: inline-block;
}
figcaption {
padding: 1em;
justify-content: center;
align-items: center;
background-color: rgba(255, 255, 255, 0.7);
}
img {
border: 2px dashed red;
}
<figure>
<img src="https://via.placeholder.com/200.jpg" alt="placeholder image used for demonstration">
<figcaption>placeholder image used for demonstration</figcaption>
</figure>