This question already has answers here:
Vertical Align Center in Bootstrap 4 [duplicate]
(20 answers)
Closed 3 years ago.
I'm trying to put some cards in a container with a parallax background effect. But while doing so, I cannot make the cards vertically centered. the row on which they are at is coming at the starting of the div. Also I want to do the container div to be relatively positioned so that the cards that are absolutely positioned will be relative to the container they're within instead of the entire page. In mobile view the cards are coming out of the div and overlapping other elements in the page. Have a look at my code below:
HTML
<div class="container-fluid parallax">
<div class="row justify-content-center">
<div class="col-lg-3 col-md-4 col-sm-8">
<div class="hovereffect">
<img class="img-responsive" src="assets/images/antoine-barres.jpg" alt="" width="350" height="200">
<div class="overlay">
<h2>Hover effect 1</h2>
<a class="info" href="#">link here</a>
</div>
</div>
</div>
<div class="col-lg-3 col-md-4 col-sm-8">
<div class="hovereffect">
<img class="img-responsive" src="assets/images/antoine-barres.jpg" alt="" width="350" height="200">
<div class="overlay">
<h2>Hover effect 1</h2>
<a class="info" href="#">link here</a>
</div>
</div>
</div>
<div class="col-lg-3 col-md-4 col-sm-8">
<div class="hovereffect">
<img class="img-responsive" src="assets/images/antoine-barres.jpg" alt="" width="350" height="200">
<div class="overlay">
<h2>Hover effect 1</h2>
<a class="info" href="#">link here</a>
</div>
</div>
</div>
</div>
</div>
CSS
.parallax {
background-image: url("/assets/images/home_services.jpg");
min-height: 500px;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.hovereffect {
width:100%;
height:100%;
float:left;
overflow:hidden;
position:relative;
text-align:center;
cursor:default;
}
.hovereffect .overlay {
width:100%;
height:100%;
position:absolute;
overflow:hidden;
top:0;
left:0;
opacity:0;
background-color:rgba(0,0,0,0.5);
-webkit-transition:all .4s ease-in-out;
transition:all .4s ease-in-out
}
.hovereffect img {
display:block;
position:relative;
-webkit-transition:all .4s linear;
transition:all .4s linear;
}
.hovereffect h2 {
text-transform:uppercase;
color:#fff;
text-align:center;
position:relative;
font-size:17px;
background:rgba(0,0,0,0.6);
-webkit-transform:translatey(-100px);
-ms-transform:translatey(-100px);
transform:translatey(-100px);
-webkit-transition:all .2s ease-in-out;
transition:all .2s ease-in-out;
padding:10px;
}
.hovereffect a.info {
text-decoration:none;
display:inline-block;
text-transform:uppercase;
color:#fff;
border:1px solid #fff;
background-color:transparent;
opacity:0;
filter:alpha(opacity=0);
-webkit-transition:all .2s ease-in-out;
transition:all .2s ease-in-out;
margin:50px 0 0;
padding:7px 14px;
}
.hovereffect a.info:hover {
box-shadow:0 0 5px #fff;
}
.hovereffect:hover img {
-ms-transform:scale(1.2);
-webkit-transform:scale(1.2);
transform:scale(1.2);
}
.hovereffect:hover .overlay {
opacity:1;
filter:alpha(opacity=100);
}
.hovereffect:hover h2,.hovereffect:hover a.info {
opacity:1;
filter:alpha(opacity=100);
-ms-transform:translatey(0);
-webkit-transform:translatey(0);
transform:translatey(0);
}
.hovereffect:hover a.info {
-webkit-transition-delay:.2s;
transition-delay:.2s;
}
My suggestion is to use flex, as the following example shows. Used most of your code, just added some background colors to make the elements visible without images.
.parallax {
background-image: url("/assets/images/home_services.jpg");
min-height: 500px;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-color: #ff0;
position: relative;
}
.hovereffect {
width: 100%;
height: 100%;
float: left;
overflow: hidden;
position: relative;
text-align: center;
cursor: default;
}
.hovereffect .overlay {
width: 100%;
height: 100%;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
opacity: 0;
background-color: rgba(0, 0, 0, 0.5);
-webkit-transition: all .4s ease-in-out;
transition: all .4s ease-in-out
}
.hovereffect img {
display: block;
position: relative;
-webkit-transition: all .4s linear;
transition: all .4s linear;
background-color: #f00;
}
.hovereffect h2 {
text-transform: uppercase;
color: #fff;
text-align: center;
position: relative;
font-size: 17px;
background: rgba(0, 0, 0, 0.6);
-webkit-transform: translatey(-100px);
-ms-transform: translatey(-100px);
transform: translatey(-100px);
-webkit-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
padding: 10px;
}
.hovereffect a.info {
text-decoration: none;
display: inline-block;
text-transform: uppercase;
color: #fff;
border: 1px solid #fff;
background-color: transparent;
opacity: 0;
filter: alpha(opacity=0);
-webkit-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
margin: 50px 0 0;
padding: 7px 14px;
}
.hovereffect a.info:hover {
box-shadow: 0 0 5px #fff;
}
.hovereffect:hover img {
-ms-transform: scale(1.2);
-webkit-transform: scale(1.2);
transform: scale(1.2);
}
.hovereffect:hover .overlay {
opacity: 1;
filter: alpha(opacity=100);
}
.hovereffect:hover h2,
.hovereffect:hover a.info {
opacity: 1;
filter: alpha(opacity=100);
-ms-transform: translatey(0);
-webkit-transform: translatey(0);
transform: translatey(0);
}
.hovereffect:hover a.info {
-webkit-transition-delay: .2s;
transition-delay: .2s;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid parallax d-flex">
<div class="row justify-content-center align-items-center">
<div class="col-3">
<div class="hovereffect">
<img class="img-responsive" src="assets/images/antoine-barres.jpg" alt="" width="350" height="200">
<div class="overlay">
<h2>Hover effect 1</h2>
<a class="info" href="#">link here</a>
</div>
</div>
</div>
<div class="col-3">
<div class="hovereffect">
<img class="img-responsive" src="assets/images/antoine-barres.jpg" alt="" width="350" height="200">
<div class="overlay">
<h2>Hover effect 1</h2>
<a class="info" href="#">link here</a>
</div>
</div>
</div>
<div class="col-3">
<div class="hovereffect">
<img class="img-responsive" src="assets/images/antoine-barres.jpg" alt="" width="350" height="200">
<div class="overlay">
<h2>Hover effect 1</h2>
<a class="info" href="#">link here</a>
</div>
</div>
</div>
</div>
</div>
One solution would be to set a a height for a common container of these images and use flexbox to align items vertically. However, this is not super dry as a solution.
So, what you could do is take your .container-fluid's container, make it a flex with .d-flex and align them with align-items-center.
Here is some reference on bootstrap 4's flex utility classes.
Related
I'm trying to build a responsive template with bootstrap 4 where there are three cards involved inside a container div. When changing the aspect ratio in mobile view, the cards are coming out of the container div and overlapping to the footer element outside it's container. Check my code below:
HTML:
<div class="container-fluid parallax">
<div class="d-flex justify-content-center">
<h1 class="title"><strong>Our Services</strong></h1>
</div>
<div class="parallax-row row justify-content-center">
<div class="parallax-cell col-sm-3">
<div class="hovereffect">
<img class="img-responsive" src="assets/images/web_dev_service.jpg" alt="" width="350" height="200">
<div class="overlay">
<h2>header</h2>
<a class="info" href="#">Know More</a>
</div>
</div>
</div>
<div class="parallax-cell col-sm-3">
<div class="hovereffect">
<img class="img-responsive" src="assets/images/digital_marketing_service.jpg" alt="" width="350" height="200">
<div class="overlay">
<h2>header</h2>
<a class="info" href="#">Know More</a>
</div>
</div>
</div>
<div class="parallax-cell col-sm-3">
<div class="hovereffect">
<img class="img-responsive" src="assets/images/creative_logo_service.jpg" alt="" width="350" height="200">
<div class="overlay">
<h2>header</h2>
<a class="info" href="#">Know More</a>
</div>
</div>
</div>
</div>
</div>
CSS:
.parallax {
background-image: url("/assets/images/home_services.jpg");
min-height: 700px;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-color: #ff0;
position: relative;
}
.parallax-row {
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
position: absolute;
}
.parallax-cell {
align-self: center;
}
.hovereffect {
width: 100%;
height: 100%;
float: left;
overflow: hidden;
position: relative;
text-align: center;
cursor: default;
border-radius: 5%;
}
.hovereffect .overlay {
width: 100%;
height: 100%;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
opacity: 0;
background-color: rgba(0, 0, 0, 0.5);
-webkit-transition: all .4s ease-in-out;
transition: all .4s ease-in-out
}
.hovereffect img {
display: block;
position: relative;
-webkit-transition: all .4s linear;
transition: all .4s linear;
background-color: #f00;
}
.hovereffect h2 {
text-transform: uppercase;
color: #fff;
text-align: center;
position: relative;
font-size: 17px;
background: rgba(0, 0, 0, 0.6);
-webkit-transform: translatey(-100px);
-ms-transform: translatey(-100px);
transform: translatey(-100px);
-webkit-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
padding: 10px;
}
.hovereffect a.info {
text-decoration: none;
display: inline-block;
text-transform: uppercase;
color: #fff;
border: 1px solid #fff;
background-color: transparent;
opacity: 0;
filter: alpha(opacity=0);
-webkit-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
margin: 50px 0 0;
padding: 7px 14px;
}
.hovereffect a.info:hover {
box-shadow: 0 0 5px #fff;
}
.hovereffect:hover img {
-ms-transform: scale(1.2);
-webkit-transform: scale(1.2);
transform: scale(1.2);
}
.hovereffect:hover .overlay {
opacity: 1;
filter: alpha(opacity=100);
}
.hovereffect:hover h2,
.hovereffect:hover a.info {
opacity: 1;
filter: alpha(opacity=100);
-ms-transform: translatey(0);
-webkit-transform: translatey(0);
transform: translatey(0);
}
.hovereffect:hover a.info {
-webkit-transition-delay: .2s;
transition-delay: .2s;
}
Just do two things.
Replace .parallax-row with below.
.parallax-row {
display: flex;
justify-content: center;
align-items: center;
}
Replace .parallax-cell with below.
.parallax-cell {
align-self: center;
margin-bottom: 20px;
}
Here is running JSFiddle - https://jsfiddle.net/t4qfvmkr/
just need to change the property min-height to height: 100% in parallax class
I am trying to make some hover effects over an image. See a demosite here. I am getting stuck now, because I would like the box there is coming when you hover to be centered on each image, no matter what the image size is.
I have tried to place the hover with padding, but that is not a good solution. Does anybody knows how I can center the gradient overlay on each picture, no matter the size og the picture?
.hovereffect {
width: 100%;
height: 100%;
float: left;
overflow: hidden;
position: relative;
text-align: center;
cursor: default;
}
.hovereffect .overlay {
width: 100%;
height: 100%;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
-webkit-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
.hovereffect:hover .overlay {
background-color: rgba(170,170,170,0.4);
}
.hovereffect h2, .hovereffect img {
-webkit-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
.hovereffect img {
display: block;
position: relative;
-webkit-transform: scale(1.1);
-ms-transform: scale(1.1);
transform: scale(1.1);
}
.hovereffect:hover img {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
.hovereffect h2 {
text-transform: uppercase;
color: #fff;
text-align: center;
position: relative;
font-size: 17px;
padding: 10px;
background: rgba(0, 0, 0, 0.6);
}
.hovereffect a.info {
display: inline-block;
text-decoration: none;
padding: 7px 14px;
text-transform: uppercase;
color: #fff;
border: 1px solid #fff;
margin: 50px 0 0 0;
background-color: transparent;
opacity: 0;
filter: alpha(opacity=0);
-webkit-transform: scale(1.5);
-ms-transform: scale(1.5);
transform: scale(1.5);
-webkit-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
font-weight: normal;
height: 85%;
width: 85%;
position: absolute;
top: -20%;
left: 8%;
padding: 70px;
}
.hovereffect:hover a.info {
opacity: 1;
filter: alpha(opacity=100);
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
background-color: rgba(0,0,0,0.4);
}
<div class="container-fluid">
<div class="row">
<div class="col-sm-12">
<div class="hovereffect">
<img class="img-responsive" src="https://www.capitalhyundai.ca/wp-content/uploads/sites/385/2017/08/2017-hyundai-elantra-gt-interior-view.jpg" alt="text"></img>
<div class="overlay">
<a class="info" href="#">link here</a>
</div>
</div>
</div>
</div>
<br/><br/>
<div class="row">
<div class="col-sm-5">
<div class="hovereffect">
<img class="img-responsive" src="https://www.carzone.ie/newcar/assets/img/models/kiasportage-abb0540cd673ba0e6dd80d5e1edc9c64.jpg" alt="text"></img>
<div class="overlay">
<a class="info" href="#">link here</a>
</div>
</div>
</div>
</div>
<br/><br/>
<div class="row">
<div class="col-sm-3">
<div class="hovereffect">
<img class="img-responsive" src="http://solcontrolcustomsandtint.com/wp-content/uploads/2014/09/car-audio-system-sound-4.jpg" alt="text"></img>
<div class="overlay">
<a class="info" href="#">link here</a>
</div>
</div>
</div>
</div>
</div>
Firt make the image container inline-block so that its width is defined by its content then you can easily adjust the overlay:
.hovereffect {
display:inline-block;
overflow: hidden;
position: relative;
text-align: center;
cursor: default;
}
.hovereffect .overlay {
width: 100%;
height: 100%;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
transition: all 0.4s ease-in-out;
}
.hovereffect:hover .overlay {
background-color: rgba(170,170,170,0.4);
}
.hovereffect h2, .hovereffect img {
transition: all 0.4s ease-in-out;
}
.hovereffect img {
display: block;
position: relative;
transform: scale(1.1);
}
.hovereffect:hover img {
transform: scale(1);
}
.hovereffect h2 {
text-transform: uppercase;
color: #fff;
text-align: center;
position: relative;
font-size: 17px;
padding: 10px;
background: rgba(0, 0, 0, 0.6);
}
.hovereffect a.info {
text-decoration: none;
text-transform: uppercase;
color: #fff;
border: 1px solid #fff;
background-color: transparent;
opacity: 0;
transform: scale(1.5);
transition: all 0.4s ease-in-out;
font-weight: normal;
height: 85%;
width: 85%;
top:7.5%; /* (100% - 85%)/2 */
left:7.5%;
position: absolute;
}
.hovereffect:hover a.info {
opacity: 1;
transform: scale(1);
background-color: rgba(0,0,0,0.4);
}
<div class="container-fluid">
<div class="row">
<div class="col-sm-12">
<div class="hovereffect">
<img class="img-responsive" src="https://www.capitalhyundai.ca/wp-content/uploads/sites/385/2017/08/2017-hyundai-elantra-gt-interior-view.jpg" alt="text"></img>
<div class="overlay">
<a class="info" href="#">link here</a>
</div>
</div>
</div>
</div>
<br/><br/>
<div class="row">
<div class="col-sm-5">
<div class="hovereffect">
<img class="img-responsive" src="https://www.carzone.ie/newcar/assets/img/models/kiasportage-abb0540cd673ba0e6dd80d5e1edc9c64.jpg" alt="text"></img>
<div class="overlay">
<a class="info" href="#">link here</a>
</div>
</div>
</div>
</div>
<br/><br/>
<div class="row">
<div class="col-sm-3">
<div class="hovereffect">
<img class="img-responsive" src="http://solcontrolcustomsandtint.com/wp-content/uploads/2014/09/car-audio-system-sound-4.jpg" alt="text"></img>
<div class="overlay">
<a class="info" href="#">link here</a>
</div>
</div>
</div>
</div>
</div>
I'm having some trouble with links. I tryed to make a cool looking hover effect on my images but destoyed the option to click a link. Obviosuly the problem is somewhere in the css transition part... I think the overlay "kills" it but I'm not a expert. Thank you for all your anwasers in advance.
HTML
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>projects</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="css2.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jquery-1.4.1.min.js"></script>
<script type="text/javascript" src="js/custom.js"></script>
</head>
<body>
<div class="logo" >
<img src="lg.png" alt="" width="180" height="178" class="logo"/>
</div>
<nav> PROJECTS ABOUT CONTACT
</nav>
<div class="ozadje">
<div class="table">
<div class="vrsta">
<div class="okno">
<div class="raste">
<img src="logo.jpg" alt="" width="300"/>
<a href="Logofolio.html" class="transition" ></a>
<div class="mask">
<h2>Logofolio</h2>
<p> Colection of my logos for a veriety of<br> different clients.</p>
</div>
</div>
</div>
<div class="okno">
<div class="raste">
<img src="vodka.jpg" alt="" width="300"/>
<a href="Logofolio.html" class="transition" ></a>
<div class="mask">
<h2>ELITE VODKA</h2>
<p> The idea was make a vodka design stand out from the competiotion and also give a strong symbolistic concept. </p>
</div>
</div>
</div>
<div class="okno">
<div class="raste">
<img src="tamn.jpg" alt="" width="300"/>
<a href="Logofolio.html" class="transition" ></a>
<div class="mask">
<h2>PERFUME DESIGN</h2>
<p> A simplistic perfume design for women. Saying as much as possible, with as little as possible but still achive clarity, balance and harmony. </p>
</div>
</div>
</div>
<div class="vrsta">
<div class="okno">
<div class="raste">
<img src="pedall.jpg" alt="" width="300"/>
<a href="Logofolio.html" class="transition" ></a>
<div class="mask">
<h2>GUITAR PEDAL</h2>
<p> You can have good sounding pedal that looks boring. What it you could have the best of<br> both worlds? </p>
</div>
</div>
</div>
<div class="okno">
<div class="raste">
<img src="keww.jpg" alt="" width="300"/>
<a href="Logofolio.html" class="transition" ></a>
<div class="mask">
<h2>Kew Guide</h2>
<p> Kew garden has a ton of beautiful sites to see all year around. Don't know where to start? Grab a brochure to make your life easy. </p>
</div>
</div>
</div>
<div class="okno">
<div class="raste">
<img src="moca.jpg" alt="" width="300"/>
<a href="Logofolio.html" class="transition" ></a>
<div class="mask">
<h2>MOCA SHOP</h2>
<p> A organic coffee shop design<br> inspired by coffee.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<footer>copyright 2016 matic toni</footer>
</body>
css
#charset "utf-8";
.logo {
padding-bottom: 0.5%;
text-align: center;
}
nav {
font-family: "Proxima";
text-align: center;
font-size: 25px;
word-spacing: 80px;
padding-right: 50px;
padding-bottom: 1%;
padding-left: 50px;
color: #000000;
}
nav:before {
border-radius: 50%;
overflow: hidden;
}
nav:before,
.table {
display: table;
margin: auto;
max-width: 600%;
}
a {
text-decoration: none;
color: black;
}
a:hover {
color: lightgray;
}
a:active {
color: black;
}
body { background-color: #F6F6F6;
margin: 0;
}
.raste img {
display: block;
border: none;
border-radius: 10px;
}
.vrsta{
overflow: hidden;
}
.okno {
display: inline-flex;
flex-wrap: wrap;
justify-content: center;
overflow: hidden;
border-radius: 10px;
}
.raste {
width: 300px;
height: 200px;
margin: 10px;
float: left;
border: solid black;
overflow: hidden;
position: relative;
text-align: center;
cursor: default;
background: black url(../images/bgimg.jpg) no-repeat center center;
border-radius: 10px;
}
.raste .mask,.raste .content {
width: 300px;
height: 200px;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
border-radius: 10px;
}
.raste img {
display: block;
position: relative;
border-radius: 10px;
}
.raste h2 {
text-transform: uppercase;
font-family: sans-serif ;
color: #fff;
text-align: center;
position: relative;
font-size: 17px;
padding: 10px;
background: rgba(0, 0, 0, 0.8);
margin: 20px 0 0 0;
}
.raste p {
font-family: Georgia, serif;
font-style: italic;
font-size: 12px;
position: relative;
color: #fff;
padding: 10px 20px 20px;
text-align: center;
}
.raste img {
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
border-radius: 10px;
}
.raste .mask {
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
background-color: rgba(149,149,149,0.62) ;
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
border-radius: 10px;
}
.raste h2 {
-webkit-transform: translateY(-100px);
-moz-transform: translateY(-100px);
-o-transform: translateY(-100px);
-ms-transform: translateY(-100px);
transform: translateY(-100px);
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
-ms-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
.raste p {
-webkit-transform: translateY(100px);
-moz-transform: translateY(100px);
-o-transform: translateY(100px);
-ms-transform: translateY(100px);
transform: translateY(100px);
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.raste:hover img {
-webkit-transform: scale(1.1,1.1);
-moz-transform: scale(1.1,1.1);
-o-transform: scale(1.1,1.1);
-ms-transform: scale(1.1,1.1);
transform: scale(1.1,1.1);
border-radius: 10px;
}
.raste:hover .mask {
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
}
.raste:hover h2,
.raste:hover p,
.raste:hover a.info {
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-o-transform: translateY(0px);
-ms-transform: translateY(0px);
transform: translateY(0px);
}
.raste:hover p {
-webkit-transition-delay: 0.1s;
-moz-transition-delay: 0.1s;
-o-transition-delay: 0.1s;
-ms-transition-delay: 0.1s;
transition-delay: 0.1s;
}
.raste:hover a.info {
-webkit-transition-delay: 0.2s;
-moz-transition-delay: 0.2s;
-o-transition-delay: 0.2s;
-ms-transition-delay: 0.2s;
transition-delay: 0.2s;
}
Change your items html like this:
<div class="okno">
<div class="raste">
<a href="Logofolio.html" class="transition" >
<img src="tamn.jpg" alt="" width="300"/>
<div class="mask">
<h2>PERFUME DESIGN</h2>
<p> A simplistic perfume design for women. Saying as much as possible, with as little as possible but still achive clarity, balance and harmony. </p>
</div>
</a>
</div>
</div>
You have to wrap your item inner html in <a> tag :)
I have what i believe to be a z-index issue with my rotate and scale hover effect.
Fiddle here
when hovering over the image it flips and scales up and shows the back side of the image with details etc.
The trouble is the images are all in rows and the margin between them is quite small. so when they scale they need to overlap on top of the images either side. at the moment this overlapping is fine to the left and to the top but overlapping is underneath on the images to the right and below.. really strange!
Here is my code - Html
<div id="games-container">
<div class="flip-container game">
<div class="flipper">
<a href="#">
<div class="front">
<h1>Front</h1>
</div>
<div class="back">
<span class="game-title">
<h3>BACK</h3>
<span class="mob-icon"></span>
</span>
<button class="button green">Play Now</button>
<button class="blue button">More Info</button>
</div>
</a>
</div>
</div>
<div class="flip-container game">
<div class="flipper">
<a href="#">
<div class="front">
<h1>Front</h1>
</div>
<div class="back">
<span class="game-title">
<h3>BACK</h3>
<span class="mob-icon"></span>
</span>
<button class="button green">Play Now</button>
<button class="blue button">More Info</button>
</div>
</a>
</div>
</div>
<div class="flip-container game">
<div class="flipper">
<a href="#">
<div class="front">
<h1>Front</h1>
</div>
<div class="back">
<span class="game-title">
<h3>BACK</h3>
<span class="mob-icon"></span>
</span>
<button class="button green">Play Now</button>
<button class="blue button">More Info</button>
</div>
</a>
</div>
</div>
CSS -
/* make things pretty */
#games-container{
width:800px;
margin:0 auto;
}
#games-container div.game{
margin: 0 8px 15px;
float: left;
position: relative;
z-index: 1;
}
#main-container div.inner-container div.game .front img, #main-container div.inner-container div.game .back img{
width:185px;
height: 145px;
}
span.game-title {
background-color:rgba(25,25,25,0.6);
display: block;
position: absolute;
width: 100%;
top: 0px;
margin-bottom: 25px;
text-align: center;
z-index: 1;
}
span.game-title h3 {
padding: 5px;
}
.game h3, .game:hover span.game-title{
color:silver;
transition:all 0.2s ease-in;
-webkit-transition:all 0.2s ease-in;
}
.game:hover h3, .game:hover span.game-title{
color:#fff;
background-color: #0c0c0c;
}
.game a{
display: block;
}
.back > .button{
position: relative;
z-index: 1;
}
.button{
display: block;
padding: 5px 10px;
margin:5px auto;
width:70%;
clear: both;
color:#fff;
}
button a{
text-decoration: none;
color:#e5e5e5;
display: block;
transition: ease-in 0.12s;
}
button.green:hover{
background-color: #00B200;
}
button:hover a{
color:#fff;
transform:scale(1.1);
}
.back > .button.green{
margin-top: 45px;
}
button{
color:#000;
border:none;
}
button.green{
background-color: #419907;
transition:background-color 0.4s ease-in;
-webkit-transition:background-color 0.4s ease-in;
}
button.blue{
background-color:#063e9b;
transition:background-color 0.4s ease-in;
-webkit-transition:background-color 0.4s ease-in
}
/* end of making things pretty*/
/* do some flipping */
.flip-container {
perspective: 900px
transform-style: preserve-3d;
}
.flip-container:hover .back {
transform: rotateY(0deg) scale(1.3);
z-index:4;
}
.flip-container:hover .front {
transform: rotateY(180deg);
}
.flip-container, .front, .back {
width: 185px;
height: 150px;
}
/* flip speed goes here */
.flipper {
transition: 0.9s;
transform-style: preserve-3d;
position: relative;
}
/* hide back of pane during swap */
.front, .back {
backface-visibility: hidden;
transition: 0.4s;
transform-style: preserve-3d;
position: absolute;
top: 0;
left: 0;
width: 185px;
height: 145px;
}
.front {
z-index: 2;
transform: rotateY(0deg);
background-color: #333;
color: #000;
text-align: center;
}
.back {
transform: rotateY(-180deg);
background-color: #010b15;
border: solid 2px #034baf;
}
Because you put the first z-index on this selector #games-container div.game, you can change the hover selector to this to remove the important property :
#games-container div.game:hover {
transform: scale(1.25);
-webkit-transform: scale(1.25);
-ms-transform: scale(1.25);
z-index: 2;
}
See it here
Add z-index: 2 !important; to .flip-container:hover
.flip-container:hover {
transform: scale(1.25);
-webkit-transform: scale(1.25);
-ms-transform: scale(1.25);
z-index: 2 !important;
}
Fiddle
I'm currently trying to create a zoom effect on hover over one of my four images. The problem is most examples usually use tables or mask divs to apply some sort of effect.
Here's one example that implements what I would like this.
This is my code so far.
HTML
<div id="menu">
<img class ="blog" src="http://s18.postimg.org/il7hbk7i1/image.png" alt="">
<img class ="music" src="http://s18.postimg.org/4st2fxgqh/image.png" alt="">
<img class ="projects" src="http://s18.postimg.org/sxtrxn115/image.png" alt="">
<img class ="bio" src="http://s18.postimg.org/5xn4lb37d/image.png" alt="">
</div>
CSS
#menu {
max-width: 1200px;
text-align: center;
margin: auto;
}
#menu img {
width: 250px;
height: 375px;
padding: 0px 5px 0px 5px;
overflow: hidden;
}
.blog {
height: 375px;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.blog:hover {
cursor: pointer;
height:475px;
width: 350px;
}
.music {
height: 375px;
}
.projects {
height: 375px;
}
.bio {
height: 375px;
}
What about using CSS3 transform property and use scale which ill give a zoom like effect, this can be done like so,
HTML
<div class="thumbnail">
<div class="image">
<img src="http://placehold.it/320x240" alt="Some awesome text"/>
</div>
</div>
CSS
.thumbnail {
width: 320px;
height: 240px;
}
.image {
width: 100%;
height: 100%;
}
.image img {
-webkit-transition: all 1s ease; /* Safari and Chrome */
-moz-transition: all 1s ease; /* Firefox */
-ms-transition: all 1s ease; /* IE 9 */
-o-transition: all 1s ease; /* Opera */
transition: all 1s ease;
}
.image:hover img {
-webkit-transform:scale(1.25); /* Safari and Chrome */
-moz-transform:scale(1.25); /* Firefox */
-ms-transform:scale(1.25); /* IE 9 */
-o-transform:scale(1.25); /* Opera */
transform:scale(1.25);
}
Here's a demo fiddle. I removed some of the element to make it simpler, you can always add overflow hidden to the .image to hide the overflow of the scaled image.
zoom property only works in IE
Here you go.
Demo
http://jsfiddle.net/27Syr/4/
HTML
<div id="menu">
<div class="fader">
<div class="text">
<p>Yay!</p>
</div>
<a href="http://stackoverflow.com/questions/15732643/jquery-masonry-and-css3/">
<img class ="blog" src="http://s18.postimg.org/il7hbk7i1/image.png" alt="">
</a>
</div>
<div class="fader">
<div class="text">
<p>Yay!</p>
</div>
<a href="http://stackoverflow.com/questions/15732643/jquery-masonry-and-css3/">
<img class ="blog" src="http://s18.postimg.org/4st2fxgqh/image.png" alt="">
</a>
</div>
<div class="fader">
<div class="text">
<p>Yay!</p>
</div>
<a href="http://stackoverflow.com/questions/15732643/jquery-masonry-and-css3/">
<img class ="projects" src="http://s18.postimg.org/sxtrxn115/image.png" alt="">
</a>
</div>
<div class="fader">
<div class="text">
<p>Yay!</p>
</div>
<a href="http://stackoverflow.com/questions/15732643/jquery-masonry-and-css3/">
<img class ="blog" src="http://s18.postimg.org/5xn4lb37d/image.png" alt="">
</a>
</div>
</div>
CSS
#menu {
text-align: center; }
.fader {
/* Giving equal sizes to each element */
width: 250px;
height: 375px;
/* Positioning elements in lines */
display: inline-block;
/* This is necessary for position:absolute to work as desired */
position: relative;
/* Preventing zoomed images to grow outside their elements */
overflow: hidden; }
.fader img {
/* Stretching the images to fill whole elements */
width: 100%;
height: 100%;
/* Preventing blank space below the image */
line-height: 0;
/* A one-second transition was to disturbing for me */
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
transition: all 0.3s ease; }
.fader img:hover {
/* Making images appear bigger and transparent on mouseover */
opacity: 0.5;
width: 120%;
height: 120%; }
.fader .text {
/* Placing text behind images */
z-index: -10;
/* Positioning text top-left conrner in the middle of elements */
position: absolute;
top: 50%;
left: 50%; }
.fader .text p {
/* Positioning text contents 50% left and top relative
to text container's top left corner */
margin-top: -50%;
margin-left: -50%; }
Suggestion
Instead of .fader { inline-block; } consider using some grid system. Based on your technology of preference, you can go Foundation, Susy, Masonry or their alternatives.
.aku {
transition: all .2s ease-in-out;
}
.aku:hover {
transform: scale(1.1);
}
I like using a background image. I find it easier and more flexible:
DEMO
CSS:
#menu {
max-width: 1200px;
text-align: center;
margin: auto;
}
.zoomimg {
display: inline-block;
width: 250px;
height: 375px;
padding: 0px 5px 0px 5px;
background-size: 100% 100%;
background-repeat: no-repeat;
background-position: center center;
transition: all .5s ease;
}
.zoomimg:hover {
cursor: pointer;
background-size: 150% 150%;
}
.blog {
background-image: url(http://s18.postimg.org/il7hbk7i1/image.png);
}
.music {
background-image: url(http://s18.postimg.org/4st2fxgqh/image.png);
}
.projects {
background-image: url(http://s18.postimg.org/sxtrxn115/image.png);
}
.bio {
background-image: url(http://s18.postimg.org/5xn4lb37d/image.png);
}
HTML:
<div id="menu">
<div class="blog zoomimg"></div>
<div class="music zoomimg"></div>
<div class="projects zoomimg"></div>
<div class="bio zoomimg"></div>
</div>
DEMO 2 with Overlay
Simply:
.grow { transition: all .2s ease-in-out; }
This will allow the element to assign an animation via css.
.grow:hover { transform: scale(1.1); }
This will make it grow!
.item:hover img
{
-moz-transform: scale(1.3);
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
this way you can zoom any image with simple animation. If you need a complete tutorial here is a official tutorial: http://talkerscode.com/webtricks/image-zoom-in-on-hover-using-css3.php
SOLUTION 1: You can download zoom-master.
SOLUTION 2: Go to here .
SOLUTION 3: Your own codes
.hover-zoom {
-moz-transition:all 0.3s;
-webkit-transition:all 0.3s;
transition:all 0.3s
}
.hover-zoom:hover {
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.5)
}
<img class="hover-zoom" src="https://i.stack.imgur.com/ewRqh.jpg"
width="100px"/>
<div class="item">
<img src="yamahdi1.jpg" alt="pepsi" width="50" height="58">
<img src="yamahdi.jpg" alt="pepsi" width="50" height="58">
<div class="item-overlay top"></div>
css:
.item img {
-moz-transition: all 0.3s;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.item img:hover {
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
-webkit-transition: all 1s ease; /* Safari and Chrome */
-moz-transition: all 1s ease; /* Firefox */
-ms-transition: all 1s ease; /* IE 9 */
-o-transition: all 1s ease; /* Opera */
transition: all 1s ease;
just want to make a note on the above transitions only need
-webkit-transition: all 1s ease; /* Safari and Chrome */
transition: all 1s ease;
and -ms- certainly doenst work for IE 9 i dont know where you got that idea from.
.img-wrap:hover img {
transform: scale(0.8);
}
.img-wrap img {
display: block;
transition: all 0.3s ease 0s;
width: 100%;
}
<div class="img-wrap">
<img src="http://www.sampleimages/images.jpg"/> // Your image
</div>
This code is only for zoom-out effect.Set the div "img-wrap" according to your styles and insert the above style results zoom-out effect.For zoom-in effect you must increase the scale value(eg: for zoom-in,use
transform: scale(1.3);
#import url('https://fonts.googleapis.com/css?family=Muli:200,300,400,700&subset=latin-ext');
body{ font-family: 'Muli', sans-serif; color:white;}
#lists {
width: 350px;
height: 460px;
overflow: hidden;
background-color:#222222;
padding:0px;
float:left;
margin: 10px;
}
.listimg {
width: 100%;
height: 220px;
overflow: hidden;
float: left;
}
#lists .listimg img {
width: 350px;
height: 220px;
-moz-transition: all 0.3s;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
#lists:hover{cursor: pointer;}
#lists:hover > .listimg img {
-moz-transform: scale(1.3);
-webkit-transform: scale(1.3);
transform: scale(1.3);
-webkit-filter: blur(5px);
filter: blur(5px);
}
#lists h1{margin:20px; display:inline-block; margin-bottom:0px; }
#lists p{margin:20px;}
.listdetail{ text-align:right; font-weight:200; padding-top:6px;padding-bottom:6px;}
<div id="lists">
<div class="listimg">
<img src="https://lh3.googleusercontent.com/WeEw5I-wk2UO-y0u3Wsv8MxprCJjxTyTzvwdEc9pcdTsZVj_yK5thdtXNDKoZcUOHlegFhx7=w1920-h914-rw">
</div>
<div class="listtext">
<h1>Eyes Lorem Impsum Samet</h1>
<p>Impsum Samet Lorem</p>
</div>
<div class="listdetail">
<p>Click for More Details...</p>
</div>
</div>
<div id="lists">
<div class="listimg">
<img src="https://lh4.googleusercontent.com/fqK7aQ7auobK_NyXRYCsL9SOpVj6SoYqVlgbOENw6IqQvEWzym_3988798NlkGDzu0MWnR-7nxIhj7g=w1920-h870-rw">
</div>
<div class="listtext">
<h1>Two Frogs Lorem Impsum Samet</h1>
<p>Impsum Samet Lorem</p>
</div>
<div class="listdetail">
<p>More Details...</p>
</div>
</div>
<!DOCTYPE html>
<html>
<head>
<style>
.zoom {
overflow: hidden;
}
.zoom img {
transition: transform .5s ease;
}
.zoom:hover img {
transform: scale(1.5);
}
</style>
</head>
<body>
<h1>Image Zoom On Hover</h1>
<div class="zoom">
<img src="/image-path-url" alt="">
</div>
</body>
</html>
Add jQuery JavaScript library together with the jquery.zbox.css and jquery.zbox.js to your webpage.
<link rel="stylesheet" href="jquery.zbox.css">
<script src="jquery.min.js"></script>
<script src="jquery.zbox.min.js"></script>
Add a group of thumbnails with links pointing to the full sized images into the webpage.
<a class="zb" rel="group" href="1.png" title="Image 1">
<img src="thumb1.png">
</a>
<a class="zb" rel="group" href="2.png" title="Image 2">
<img src="thumb2.png">
</a>
<a class="zb" rel="group" href="3.png" title="Image 3">
<img src="thumb3.png">
</a>
Call the function on document ready. That's it.
In the view source do:
$(".zb").zbox();