I have a 2 by 2 CSS Grid. Each grid box has a circular button. The desired UI is something like:
Instead, my UI is in a dismal state, as shown below:
I suspect the main reason to be the transform: translateY(k%);, which I used to move the buttons around in my code editor, but they don't seem to be very responsive. How can I resolve this error? I've already tried accommodating the solution at Centering CSS Grid by using flexbox, but to no avail. Here is the relevant code:
.container{
display: grid;
grid-gap: 20px;
height: 97vh;
width: 97vw;
grid-template-columns: 1fr 1fr;
grid-template-rows: auto;
grid-template-areas:
"blockOne blockTwo"
"blockThree blockFour"
}
.item{
background-color: whitesmoke;
border: 0px solid black;
box-shadow: 5px 5px;
}
.block1{
grid-area: blockOne;
}
.block2{
grid-area: blockTwo;
height: 100%;
}
.block3{
grid-area: blockThree;
height: 100%;
}
.block4{
grid-area: blockFour;
height: 100%;
}
.item:hover{
background-color: lightblue;
transition: ease 0.3s;
}
*{
transition: ease 0.3s;
}
.call{
background-color: black;
width: 250px;
height: 250px;
border-radius: 150px;
margin: 0 auto;
position: relative;
top: 50%;
transform: translateY(30%);
box-shadow: 5px 5px;
background-image: url("https://www.levelaccess.com/wp-content/uploads/2017/11/CVAA-02.png");
background-position: center;
background-size: 230px;
transition: 0.70s ease;
}
.call:hover{
transition: 0.70s ease;
background-color: whitesmoke;
}
.info{
background-image: white;
width: 250px;
height: 250px;
border-radius: 150px;
margin: 0 auto;
position: relative;
top: 50%;
transform: translateY(-50%);
box-shadow: 5px 5px;
background-image: url("https://s3.us-east-2.amazonaws.com/upload-icon/uploads/icons/png/5851494071557740370-512.png");
background-size: cover;
background-position: center;
background-size: 100px;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
.info:hover{
background-size: 300px;
}
.rehab{
background-color: red;
width: 250px;
height: 250px;
border-radius: 150px;
margin: 0 auto;
position: relative;
top: 50%;
transform: translateY(-50%);
box-shadow: 5px 5px;
background-image: url("data:image/=");
background-position: center;
background-size: contain;
background-size: 50px;
}
.rehab:hover{
background-size: 100%;
}
.CPR{
background-color: red;
width: 250px;
height: 250px;
border-radius: 150px;
margin: 0 auto;
position: relative;
top: 50%;
transform: translateY(-50%);
box-shadow: 5px 5px;
background-image: url("https://www.humankind.org/wp-content/uploads/2018/08/ems-icon-doing-cpr-300x300.png");
background-size: cover;
transition: 0.3s ease-in-out;
}
.CPR:hover{
background-image:url("https://thumbs.gfycat.com/AdmiredGorgeousHousefly-size_restricted.gif");
background-size: contain;
background-position: 5px 45px;
transition: 0.3s ease-in-out;
}
The website itself is at refath.github.io/I-Care. Any help is greatly appreciated. Thank you.
There are few mistakes in your HTML code. DIVs were not properly closed.
.container{
display: grid;
grid-gap: 20px;
height: 97vh;
width: 97vw;
grid-template-columns: 1fr 1fr;
grid-template-rows: auto;
grid-template-areas:
"blockOne blockTwo"
"blockThree blockFour"
}
.item{
background-color: whitesmoke;
border: 0px solid black;
box-shadow: 5px 5px;
position:relative;
padding:50px 0px;
}
.block1{
grid-area: blockOne;
}
.block2{
grid-area: blockTwo;
}
.block3{
grid-area: blockThree;
}
.block4{
grid-area: blockFour;
}
.item:hover{
background-color: lightblue;
transition: ease 0.3s;
}
*{
transition: ease 0.3s;
}
.call{
background-color: black;
width: 250px;
height: 250px;
border-radius: 150px;
margin: 0 auto;
top: 50%;
box-shadow: 5px 5px;
background-image: url("https://www.levelaccess.com/wp-content/uploads/2017/11/CVAA-02.png");
background-position: center;
background-size: 230px;
transition: 0.70s ease;
}
.call:hover{
transition: 0.70s ease;
background-color: whitesmoke;
}
.info{
background-image: white;
width: 250px;
height: 250px;
border-radius: 150px;
margin: 0 auto;
top: 50%;
box-shadow: 5px 5px;
background-image: url("https://s3.us-east-2.amazonaws.com/upload-icon/uploads/icons/png/5851494071557740370-512.png");
background-size: cover;
background-position: center;
background-size: 100px;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
.info:hover{
background-size: 300px;
}
.rehab{
background-color: red;
width: 250px;
height: 250px;
border-radius: 150px;
margin: 0 auto;
top: 50%;
box-shadow: 5px 5px;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSU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7UbI6ao1Eb1AZqcEKeR31TqIAefcYL1CO12zjeDEYPiiNMeDCdGeim2EJQbDH3oHIIQQDTlMIyDR1GcsRMZFRI85UEQveTH0AQjR8TiPqCIHBDFIkjeD4w9QiGK2in1gojd81Z0f8IARokFnHuINaUQMkuBZsgxTGVBCFJuFX0ZqE1HvfGFcn6YbgEJ7iwxNiEHivUiVQaUDVohiMp/G26ZUJQbe8PJZY/cgDnAhinS26EWRHyoQAy9JPr/MAIZOKuoQZpFu5k9+HHlBUGVDuGHy8+1bHbos6hLmkU76L68nCJB4xbWKJVd21WGSJCev4/59Xbg8ahUWkY7uN/2355efr6+Xl59PPl9evr7+fHl+62/uR7Xaivg/4y/Z4+h5F1IAAAAASUVORK5CYII=");
background-position: center;
background-size: contain;
background-size: 50px;
}
.rehab:hover{
background-size: 100%;
}
.CPR{
background-color: red;
width: 250px;
height: 250px;
border-radius: 150px;
margin: 0 auto;
top: 50%;
box-shadow: 5px 5px;
background-image: url("https://www.humankind.org/wp-content/uploads/2018/08/ems-icon-doing-cpr-300x300.png");
background-size: cover;
transition: 0.3s ease-in-out;
}
.CPR:hover{
background-image:url("https://thumbs.gfycat.com/AdmiredGorgeousHousefly-size_restricted.gif");
background-size: contain;
background-position: 5px 45px;
transition: 0.3s ease-in-out;
}
<body data-gr-c-s-loaded="true"><div class="container">
<div class="item block1">
<a href="https://hangouts.google.com/webchat/start"><div class="call">
</div></a>
</div>
<div class="item block2">
<a href="https://cdpn.io/Refath/debug/dyoPmow/YvAgOeRgYVOA">
<div class="info">
</div>
</a>
</div>
<div class="item block3">
<a href="https://cdpn.io/Refath/debug/VwLYBjR/mVMbGDRgQKgr"><div class="item block3">
<div class="rehab">
</div>
</div></a>
</div>
<div class="item block4">
<a href="https://cdpn.io/Refath/debug/mdJyOpa/PNAvYKZKoNpr"><div class="item block4">
<div class="CPR">
</div>
</div></a>
</div>
</body>
I have edited your code to achieve how you wanted it to be.
https://jsfiddle.net/rajeevRF/nz1upcx8/7/
Related
This is the current code I made, the rotations and animations are okay, but I can't make a hover text in the image of the planet or the orbit of the planet.
<html>
<head>
<style>
body {
background-image: url(bg.jpg);
background-size: cover;
}
I can't make a hover with this while the planets were animating.
.sun {
left:700px;
top:300px;
height: 170px;
width: 170px;
background-image: url("sun.png");
background-repeat: cover;
background-size: 100%;
position: absolute;
margin: 0;
}
the planet or the orbit of the planet when you hover it, it should show the text or the name of the planet itself.
.mercury {
left:680px;
top:343px;
height: 40px;
width: 40px;
background-image: url("mercury.png");
background-repeat: no-repeat;
background-size: 100%;
position: absolute;
transform-origin: 280% 90%;
animation: rotate 1.5s infinite linear;
}
.mercuryOrbit {
left:690px;
top:285px;
height: 190px;
width: 190px;
background-color: transparent;
border-radius: 50%;
border-style: dashed;
border-color: gray;
position: absolute;
border-width: 1px;
margin: 0px;
padding: 0px;
}
.venus {
left:600px;
top:330px;
height: 50px;
width: 50px;
background-image: url("venus.png");
background-repeat: no-repeat;
background-size: 100%;
position: absolute;
transform-origin: 370% 80%;
animation: rotate 3.84s infinite linear;
}
.venusOrbit {
left:620px;
top:210px;
height: 330px;
width: 330px;
background-color: transparent;
border-radius: 50%;
border-style: dashed;
border-color: gray;
position: absolute;
border-width: 1px;
margin: 0px;
padding: 0px;
}
.earth {
left:535px;
top:300px;
height: 70px;
width: 70px;
background-image: url("earth.png");
background-repeat: no-repeat;
background-size: 100%;
position: absolute;
transform-origin: 350% 100%;
animation: rotate 6.25s infinite linear;
}
.earthOrbit {
left:570px;
top:160px;
height: 430px;
width: 430px;
background-color: transparent;
border-radius: 50%;
border-style: dashed;
border-color: gray;
position: absolute;
border-width: 1px;
margin: 0px;
padding: 0px;
}
#keyframes rotate {
100% {
transform: rotate(-360deg);
}
}
</style>
</head>
<body>
<div class=“solarsys”>
<div class="sun"></div>
<div class="mercuryOrbit"></div>
<div class="mercury"></div>
<div class="venusOrbit"></div>
<div class="venus"></div>
<div class="earthOrbit"></div>
<div class="earth"></div>
</div>
</body>
</html>
How can I add hover effect on the image so that the name of the planet will show? I don't know how to add it.
This issue may stem from the orbits overlapping on your planets. Try adding z-index : 1 for example to one of your planet class and test the hovering again.
Here is an example:
.mercury {
/* rest of your class here */
position: relative;
z-index: 1;
}
.mercury::after {
content: "Hello world";
position: absolute;
font-size: 0.8rem;
background-color: #3f3f3f;
border-radius: 3px;
padding: 0.2rem;
bottom: 100%;
left: 0;
color: white;
display: none;
}
.mercury:hover.mercury::after {
display: block;
}
For more informations on z-index:
https://developer.mozilla.org/en-US/docs/Web/CSS/z-index
This question already has answers here:
Use CSS3 transitions with gradient backgrounds
(19 answers)
Closed 1 year ago.
.body {
background-color: #18181a;
color: white;
font-size: 2.5rem;
margin-left: 0%;
border-radius: 5px;
}
.body .card{
background:linear-gradient(90deg, rgba(0,0,0,1) 0%, rgba(0,212,255,0) 100%),url("./images/yuuki_mikan_bg.jpg");
background-repeat: no-repeat;
background-position: right;
width: 90%;
height: 80%;
border-radius: 10px;
margin: 10px;
margin-left: auto;
margin-right: auto;
display: flex;
justify-content: space-between;
flex-direction: row-reverse;
transition: background 0.5s linear;
}
.body .card:hover {
background:linear-gradient(90deg, rgba(0,0,0,0.17690826330532217) 0%, rgba(0,212,255,0) 100%),url("./images/yuuki_mikan_bg.jpg");
background-position: right;
}
.body .card .card_img{
max-width: 80%;
max-height: 95%;
border-radius: 5px;
/* bottom: 9px; */
/* left: -10px; */
/* top: -10px; */
transition: 0.5s;
opacity: 1;
display: flex;
justify-content: flex-start;
align-self: center;
}
.body .card .card_name{
margin-right: 2%;
margin-top: auto;
margin-bottom: auto;
font-size: 2.5rem;
text-shadow: 0px 0px 18px black;
opacity: 1;
}
this is the code im using, whenever i hover over .card, it changes the background color but transition doesn't delay its transition time. If you want more context, this is the website my code is running at https://oniichann.tk/waifus
I believe the only animatable property on a background gradient is background-position.
You may be able to achieve what you're looking for by doing something like the following:
.card {
position: relative;
text-align: center;
color: white;
padding: 100px;
background: url("https://oniichann.tk/waifus/images/bg.jpg");
background-repeat: no-repeat;
background-position: right;
background-size: cover;
}
.card:before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(
90deg,
rgba(0, 0, 0, 1) 0%,
rgba(0, 0, 0, 0) 100%
);
background-size: 200% 200%;
transition: background-position 0.5s linear;
}
.card:hover:before {
background-position: 100% 50%;
}
<div class="card"></div>
My issue is that I can select the text on the front of the card even when the card is flipped and the only thing being shown is the back of the card. I do not understand why is that happening.
Here's a gif demonstrating the issue:
https://imgur.com/a/erdcUCG
Thank you for taking the time to help me!
HTML for one card:
<div class="pricing-container">
<!-- Card 1 -->
<div class="pricing-container__card-container">
<div class="card-1 cards">
<figure class="card-1__front">
<div class="card-1__front-top">
<h1 class="card-headers">Pack 1</h1>
</div>
<div class="card-1__front-bottom">
<ul class="card-1__front-bottom-list">
<li class="list-items">lorem</li>
<li class="list-items">lorem</li>
<li class="list-items">lorem</li>
<li class="list-items">lorem</li>
<li class="list-items">lorem</li>
</ul>
</div>
</figure>
<figure class="card-1__back">
<h1>PRICE: $20</h1>
<button class="pricing-container__btn">BUY</button>
</figure>
</div>
</div>
SCSS:
.pricing-container{
width: 100%;
height: 100vh;
background: var(--color-primary);
display: flex;
justify-content: space-evenly;
align-items: center;
&__card-container{
width: 45rem;
height: 65rem;
&:hover .cards{
transform: rotateY(180deg);
}
}
&__btn{
margin-top: 3rem;
border: none;
width: 20rem;
height: 7rem;
border-radius: 50px;
font-size: 2.7rem;
font-weight: bold;
background: linear-gradient(to bottom right, var(--color-card-btn-gradient-1), var(--color-card-btn-gradient-2));
color: #fff;
position: absolute;
bottom: 8rem;
cursor: pointer;
}
}
.cards{
width: 100%;
height: 100%;
-webkit-transition: -webkit-transform .8s;
transition: transform .8s ease-in-out;
transform-style: preserve-3d;
}
.card-1, .card-2, .card-3{
overflow-x: visible;
position: relative;
&__front{
background: var(--color-secondary);
// transform: rotateY(0deg);
&-top{
position: absolute;
top: 0;
width: 100%;
height: 35%;
border-radius: 20px 20px 0 0;
font-size: 3.2rem;
color: var(--color-secondary);
background: rgba($color: #000000, $alpha: .25);
background-blend-mode: multiply;
display: flex;
justify-content: center;
align-items: center;
}
}
&__front-bottom{
position: absolute;
top: 50%;
&-list{
color: var(--color-primary);
font-size: 3.5rem;
font-weight: 600;
list-style: none;
}
}
&__back{
background: linear-gradient(to bottom right, var(--color-card-gradient-1), var(--color-card-gradient-2));
color: var(--color-secondary);
transform: rotateY(180deg);
& h1{
position: absolute;
top: 20rem;
font-size: 5rem;
}
&::before{
content: "";
width: 60%;
height: 35%;
position: absolute;
background-image:url(../img/bg-svg.png);
background-size: cover;
top: 1.5rem;
left: 1.5rem;
}
}
figure{
margin: 0;
width: 100%;
height: 100%;
border-radius: 20px;
border: none;
position: absolute;
display: flex;
flex-direction: column;
justify-content: space-evenly;
align-items: center;
-moz-backface-visibility: hidden;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
}
.card-1{
&__front{
&-top{
background-image: url("../img/card-1-photo.jpg");
clip-path: polygon(0% 0%, 100% 0%, 100% 90%, 0% 100%);
background-size: cover;
}
}
}
.card-2{
&__front{
&-top{
background-image: url("../img/card-2-photo.jpg");
clip-path: polygon(0% 0%, 100% 0%, 100% 90%, 0% 100%);
background-size: cover;
}
}
}
.card-3{
&__front{
&-top{
background-image: url("../img/card-3-photo.jpg");
clip-path: polygon(0% 0%, 100% 0%, 100% 90%, 0% 100%);
background-size: cover;
}
}
}
Not so bad, are you sure it needs to be fixed?
If this works using a hover, you can try setting the text to display:hidden; on hover - or whatever the event is.
Problem fixed.
I used javascript to apply a class with --visibility: hidden-- [EDIT: ended up using display: none because of interaction issues] to the list element. --That way I can use the transition property to delay the disappearance of the element until the user flips the card completely.-- [EDIT: It was a good idea at the beginning haha]
I want a border around my image which is translucent showing 'background' (i.e. not the picture). As the css order is content, padding, border, margin, so I would expect the border around my picture-content, but probably because my picture is set as background (to make it scale) it does not work as I expected. Now it shows parts of my picture through my lightgrey border, see e.g.:
and
How do I get my border around my picture?
body {
background-color: #fff;
margin: 0 0;
padding: 0 0;
}
.overlay {
display: flex;
position: absolute;
background-color: #808080;
cursor: pointer;
color: #f00;
flex-flow: row nowrap;
justify-content: flex-start;
height: 40vh;
width: 100vw;
bottom: 0;
left: 0;
margin: 0;
overflow-y: hidden;
overflow-x: scroll;
}
.overlay .item-image {
border-radius: 5px;
flex: 1 1 auto;
min-width: 45vw;
width: 45vw;
margin-left: 4vw;
border: 15px solid rgba(255,255,255,0.3);
border-radius: 2px;
}
<meta name="description" content="Transparent border not working">
<body>
<div class="overlay">
<div class="item-image" style='background: url(http://previews.123rf.com/images/bagiuiani/bagiuiani1003/bagiuiani100300014/15165060-Mellons-Stock-Photo.jpg) no-repeat 20% center; background-size: cover;'>
</div>
<div class="item-image" style='background: url(http://previews.123rf.com/images/bagiuiani/bagiuiani1003/bagiuiani100300014/15165060-Mellons-Stock-Photo.jpg) no-repeat 20% center; background-size: cover;'>
</div>
</div>
</body>
The property you are probably looking for is background-clip. Set the value either to content-box or padding-box and the result is that the background-image won't continue under the border (which by the way is caused by the fact that the image dimensions are different from the dimensions of the div and background-size: cover).
body {
background-color: #fff;
margin: 0 0;
padding: 0 0;
}
.overlay {
display: flex;
position: absolute;
background-color: #808080;
cursor: pointer;
color: #f00;
flex-flow: row nowrap;
justify-content: flex-start;
height: 40vh;
width: 100vw;
bottom: 0;
left: 0;
margin: 0;
overflow-y: hidden;
overflow-x: scroll;
}
.overlay .item-image {
border-radius: 5px;
flex: 1 1 auto;
min-width: 45vw;
width: 45vw;
margin-left: 4vw;
border: 15px solid rgba(255, 255, 255, 0.3);
border-radius: 2px;
}
<meta name="description" content="Transparent border not working">
<body>
<div class="overlay">
<div class="item-image" style='background: url(http://previews.123rf.com/images/bagiuiani/bagiuiani1003/bagiuiani100300014/15165060-Mellons-Stock-Photo.jpg) no-repeat 20% center; background-size: cover; background-clip: content-box'>
</div>
<div class="item-image" style='background: url(http://previews.123rf.com/images/bagiuiani/bagiuiani1003/bagiuiani100300014/15165060-Mellons-Stock-Photo.jpg) no-repeat 20% center; background-size: cover; background-clip: content-box'>
</div>
</div>
</body>
Just in case I misunderstood the question and you want to have a transparent border on all sides, you could do it like this:
body {
background-color: #fff;
margin: 0 0;
padding: 0 0;
}
.overlay {
display: flex;
position: absolute;
background-color: #808080;
cursor: pointer;
color: #f00;
flex-flow: row nowrap;
justify-content: flex-start;
height: 40vh;
width: 100vw;
bottom: 0;
left: 0;
margin: 0;
overflow-y: hidden;
overflow-x: scroll;
}
.overlay .item-image {
position: relative;
border-radius: 5px;
flex: 1 1 auto;
min-width: 45vw;
width: 45vw;
margin-left: 4vw;
}
.overlay .item-image:after {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border: 15px solid rgba(255, 255, 255, 0.3);
}
<meta name="description" content="Transparent border not working">
<body>
<div class="overlay">
<div class="item-image" style='background: url(http://previews.123rf.com/images/bagiuiani/bagiuiani1003/bagiuiani100300014/15165060-Mellons-Stock-Photo.jpg) no-repeat 20% center; background-size: cover;'>
</div>
<div class="item-image" style='background: url(http://previews.123rf.com/images/bagiuiani/bagiuiani1003/bagiuiani100300014/15165060-Mellons-Stock-Photo.jpg) no-repeat 20% center; background-size: cover;'>
</div>
</div>
</body>
I am trying to archieve a zoom in my background's in divs. I don't want the div to be bigger, but I want the image to zoom on hover, without growing the div. I have tried everything, but I can't seem to get it to work.
CSS:
/* Theme */
html {
margin-top: 0px !important;
}
/* DO NOT EDIT OR MONKEYS WILL BITE YOU */
.frame_holder {
position: absolute;
top: 8px;
bottom: 50px;
/* left: 50px; */
right: 150px;
background: #ffffff;
}
.my_frame {
width: 149%;
height: 108%;
/* border: 1px solid #e0e0e0; */
}
body {
background-color: #f0ede9;
margin-top: 0px;
position: relative;
background-repeat: no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.clearfix {
clear: both;
}
p {
font-family: Roboto;
padding: 1px;
}
#body.layout-1 {
background: #f0ede9 url(../images/border.gif) 640px top repeat-y scroll;
background-color: #f0ede9;
background-image: url(../images/border.gif), url(../images/border-2.gif);
background-repeat: repeat-y, repeat-y;
background-position: 640px top, 0px top;
}
a:hover, a:visited, a:link, a:active {
text-decoration: none;
color: #bababa;
font-family: Roboto;
}
#wrapper {
width: 1200px;
margin: 0 auto;
}
#header {
width: 100%;
height: 80px;
background: #2a2727;
margin-top: 20px;
color: #fff;
}
.top-logo-container {
display: block;
height: 100px;
width: 100px;
text-indent: -9999px;
background: url(http://favoritefm.com/wp-content/themes/FavClear/img/logo.png) 5% 50% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 100px;
}
#main {
margin-left: 2px;
}
.presenter-ribbon {
display: block;
position: absolute;
left: -5px;
top: 20px;
color: #fff;
background-color: #de1f26;
font-size: 12px;
line-height: 30px;
padding: 0 20px 0 30px;
font-family: 'Roboto Condensed',sans-serif;
font-weight: 700;
text-shadow: 0 -1px 0 rgba(0,0,0,.2);
text-transform: uppercase;
z-index: 20;
text-decoration: none;
box-shadow: 0 1px 2px 0 rgba(0,0,0,.25);
}
#presenter {
margin-top: 40px;
width: 100%;
height: 100%;
}
.box-link {
display: block;
position: absolute;
overflow: hidden;
box-sizing: border-box;
padding: 60px 20px 10px;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-size: cover;
background-position: center center;
-webkit-transition: all .1s linear;
-moz-transition: all .1s linear;
-ms-transition: all .1s linear;
-o-transition: all .1s linear;
}
.box-link .box-overlay {
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0,0,0,.15);
z-index: 10;
box-shadow: 5px 5px 10px 0 rgba(0,0,0,.2) inset;
-webkit-transition: all .2s linear;
-moz-transition: all .2s linear;
-ms-transition: all .2s linear;
-o-transition: all .2s linear;
}
.box-link .box-overlay:hover {
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0,0,0,.15);
z-index: 10;
box-shadow: 5px 5px 10px 0 rgba(0,0,0,.2) inset;
-webkit-transition: all .2s linear;
-moz-transition: all .2s linear;
-ms-transition: all .2s linear;
-o-transition: all .2s linear;
}
.box-link .box-visual {
display: block;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-size: cover;
background-position: center center;
z-index: 5;
max-width: 100%;
-moz-transition: all 0.3s;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.box-link .box-visual:hover {
display: block;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-size: cover;
background-position: center center;
z-index: 5;
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.1);
opacity: 0.7;
}
.box-link h4 {
display: block;
color: #fff;
text-decoration: none;
text-shadow: 0 1px 2px rgba(0,0,0,.8);
z-index: 20;
position: absolute;
bottom: 20px;
left: 20px;
right: 20px;
margin-bottom: 0;
}
.box-link h4 {
font-size: 22px;
line-height: 34px;
}
.presenter-one {
display: block;
height: 49.65%;
width: 50%;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
-webkit-transition: all .2s linear;
-moz-transition: all .2s linear;
-ms-transition: all .2s linear;
-o-transition: all .2s linear;
}
.presenter-two {
float: left;
position: relative;
display: block;
height: 25%;
width: 25%;
background: url(http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg) 0% 0% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 100% 100%;
}
.presenter-three {
position: relative;
display: block;
height: 25%;
width: 25%;
background: url(http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg) 0% 0% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 100% 100%;
}
.presenter-four {
position: relative;
display: block;
height: 25.4%;
width: 25%;
background: url(http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg) 0% 0% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 100% 100%;
}
.presenter-five {
position: relative;
display: block;
height: 25.4%;
width: 25%;
background: url(http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg) 0% 0% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 100% 100%;
}
}
#media screen and (min-width: 737px) and (max-width: 1200px) {
#wrapper {
width: 100%
}
}
#media screen and (min-width: 737px) and (max-width: 1200px) {
#wrapper {
width: 100%
}
}
#media screen and (max-width: 736px) and (min-width: 415px) {
#wrapper {
width: 100%
}
#header {
width: 100%;
background: #2a2727;
color: #fff;
margin-top: 0px;
height: 100px;
}
.top-logo-container {
display: block;
height: 120px;
width: 120px;
background: url(http://favoritefm.com/wp-content/themes/FavClear/img/logo.png) 5% 50% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 120px;
}
#main {
margin-left: 2px;
}
#presenter {
margin-top: 40px;
width: 100%;
height: 100%;
}
.presenter-one {
display: block;
height: 50%;
width: 100%;
background: url(http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg) 0% 0% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 100% 100%;
}
.presenter-two {
display: block;
height: 50%;
width: 50%;
background: url(http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg) 0% 0% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 100% 100%;
}
.presenter-three {
display: block;
height: 50%;
width: 50%;
background: url(http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg) 0% 0% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 100% 100%;
}
.presenter-four {
display: block;
height: 50%;
width: 50%;
background: url(http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg) 0% 0% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 100% 100%;
}
.presenter-five {
display: block;
height: 50%;
width: 50%;
background: url(http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg) 0% 0% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 100% 100%;
}
}
#media screen and (max-width: 414px) and (min-width: 1px) {
#wrapper {
width: 100%
}
#header {
width: 100%;
background: #2a2727;
color: #fff;
margin-top: 0px;
height: 100px;
}
.top-logo-container {
display: block;
height: 120px;
width: 120px;
background: url(http://favoritefm.com/wp-content/themes/FavClear/img/logo.png) 5% 50% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 120px;
}
#main {
margin-left: 2px;
}
#presenter {
margin-top: 40px;
width: 100%;
height: 100%;
}
.presenter-one {
display: block;
height: 50%;
width: 100%;
background: url(http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg) 0% 0% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 100% 100%;
}
.presenter-two {
display: block;
height: 50%;
width: 50%;
background: url(http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg) 0% 0% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 100% 100%;
}
.presenter-three {
display: block;
height: 50%;
width: 50%;
background: url(http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg) 0% 0% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 100% 100%;
}
.presenter-four {
display: block;
height: 50%;
width: 50%;
background: url(http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg) 0% 0% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 100% 100%;
}
.presenter-five {
display: block;
height: 50%;
width: 50%;
background: url(http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg) 0% 0% no-repeat scroll;
margin: 0 auto;
position: relative;
float: left;
background-color: #000;
margin-top: -10px;
background-size: 100% 100%;
}
}
https://jsfiddle.net/9b7fvfk6/
HTML:
<meta name="viewport" content="width=device-width" />
<div id="wrapper">
<div id="header"></div>
<div id="main">
<div id="presenter">
<div class="presenter-one"><a class="presenter-ribbon" href="/Testcategorie" ng-if="element.ribon">Testcategorie</a><a class="box-link" href="/airfield"><h4 class="ng-binding">Dit is een testregel!</h4><span class="box-overlay"></span> <span class="box-visual" style="background-image: url('http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg')"></span></a></div>
<div class="presenter-two"><a class="presenter-ribbon" href="/Testcategorie" ng-if="element.ribon">Testcategorie</a><a class="box-link" href="/airfield"><h4 class="ng-binding">Dit is een testregel!</h4><span class="box-overlay"></span> <span class="box-visual" style="background-image: url('http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg')"></span></a></div>
<div class="presenter-three"><a class="presenter-ribbon" href="/Testcategorie" ng-if="element.ribon">Testcategorie</a><a class="box-link" href="/airfield"><h4 class="ng-binding">Dit is een testregel!</h4><span class="box-overlay"></span> <span class="box-visual" style="background-image: url('http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg')"></span></a></div>
<div class="presenter-four"><a class="presenter-ribbon" href="/Testcategorie" ng-if="element.ribon">Testcategorie</a><a class="box-link" href="/airfield"><h4 class="ng-binding">Dit is een testregel!</h4><span class="box-overlay"></span> <span class="box-visual" style="background-image: url('http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg')"></span></a></div>
<div class="presenter-five"><a class="presenter-ribbon" href="/Testcategorie" ng-if="element.ribon">Testcategorie</a><a class="box-link" href="/airfield"><h4 class="ng-binding">Dit is een testregel!</h4><span class="box-overlay"></span> <span class="box-visual" style="background-image: url('http://eastsbeach.com.au/assets/Uploads/_resampled/SetWidth2000-Kiama-Events-Easts-Beach-PB.jpg')"></span></a></div>
</div>
</div>
Is there anyone who can help me? I thought I would have to make a box-visual:hover, but that's not doing anything either. :-(
Change the hover to the .box-link should makes it working. Example:
.box-link:hover .box-visual {
transform: scale(1.1);
}
See Updated Fiddle
If you don't want the image to cross the borders of the div, set the div CSS property to overflow: hidden;
.container {
border: 2px solid black;
height: 300px;
width: 300px;
overflow: hidden;
}
img:hover {
transform: scale(1.5);
}
<div class="container">
<img src="http://goo.gl/1ex50e"/>
</div>