css transition is not working on gradients? [duplicate] - css

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>

Related

Tricky CSS Positioning Animation

I'm learning about CSS animations and am trying to animate this stamp which uses relative and absolute positioning. I want the animation to:
Start at it's original size.
Grow 2-3xs that size and be at the center of the screen.
Pause for 2-3 seconds seconds.
Shrink back down to it's original size and spot.
The problem I'm running into is keeping the elements positioned on top of the stamp in the same place as the transitions occur. Looking to keep it pure CSS if possible (*side note I haven't added any web-kit/browser support yet because I'm just trying to make it work first).
Here is the code:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
height: 90vh;
justify-content: flex-end;
align-items: flex-start;
background: grey;
}
.park-img {
width: 10rem;
height: 11.2rem;
display: inline-block;
margin-left: 2px;
padding: 10px;
background: white;
position: relative;
top: 2rem;
left: -2rem;
/*-webkit-filter: drop-shadow(0px 0px 10px rgba(0,0,0,0.5));
/*The stamp cutout will be created using crisp radial gradients*/
background: radial-gradient( transparent 0px, transparent 4px, white 4px, white);
/*reducing the gradient size*/
background-size: 20px 20px;
/*Offset to move the holes to the edge*/
background-position: -10px -10px;
/*Animation*/
animation: stampAnimation 9s ease-in-out;
}
#keyframes stampAnimation {
0% {}
50% {
transform: scale(3, 3) translate(-35%, 35%);
}
75% {
transform: scale(3, 3) translate(-35%, 35%);
}
}
.stampText {
position: relative;
top: -1rem;
left: -1.8rem;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
color: #fafafa;
text-transform: uppercase;
animation: stampAnimation 9s ease-in-out;
}
.park-name {
font-weight: bold;
text-align: center;
font-size: 1rem;
}
.park-title {
width: 90%;
overflow: hidden;
text-align: center;
font-size: .5rem;
}
.park-title:before,
.park-title:after {
background-color: #fafafa;
content: "";
display: inline-block;
height: 1px;
position: relative;
vertical-align: middle;
width: 10%;
}
.park-title:before {
right: 0.5rem;
margin-left: -50%;
}
.park-title:after {
left: 0.5rem;
margin-right: -50%;
}
<div class="park-stamp">
<img src="https://res.cloudinary.com/saveallthethings/image/upload/v1614633821/daniel-burka-X_IwSPO2GH0-unsplash_zvoyst.jpg" class="park-img" />
<div class="stampText">
<div class="park-name">Zion</div>
<div class="park-title">National Park</div>
</div>
</div>
As well as the codepen:
https://codepen.io/aspirationalhobbit/pen/GRNPqxw?editors=0100
I have edited your code to make changes that are different from my initial answer.
Check https://codepen.io/udabasili/pen/VwmqmQK?editors=1100.
Basically, I created a css for the container of your element and moved the animation there. I also removed the translate from your animation. Check the css in the codepen to see the changes
.park-stamp{
animation: stampAnimation 9s ease-in-out infinite;
}

Centering Div in CSS Grid

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,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAA1VBMVEXgW0n////JUUHr8PPV1ttkeYrh5uknotvq7/Lp6enJSTbV1Njk6ezlY1PgVD9uyurNz9VleotYbX7ITDpNrd3UVkXfVkPNXE0nQlPb2+Dr9fnKV0jeTzreSzXIRTHhycnK3efosa3WvL6fy+MIndp1ueCm1ejFPSj65uTpy8rnmZL21NDialsqpNxnxujywbxKtOJZveXspJzoj4X88O/uraaJyeaHweHkdGXmg3f219T54+Hq3d7zyMPjaVnleWzdmpLXhHrQaFvgu7nVfXLhoprScmaAH30eAAAMyElEQVR4nN3d+X+bRhYAcDCtjImEu8XBGwfoaqNGiiRbtoS2kh35apz//0/aAXQwJ3M8ZOj7IW1e/bH07QxzPC7Lrj/S+01/OV6sV9PHXs/q9R6nq/VivOxv7tMjfLpV5y9P72fjp54fR5Hvh2FoHQL9zfejKPZ7T+NZvdC6hOlm/oRoPuZiBaIi6NN8UxezDmE6W/RQs1XZMCdq0N5iVocSXDiZT+NIBVdiRvF0PoH+QrDCzcJXaztGW/qLDeh3AhROEM9Ed2hKfwHYklDC0TwE4e2Q4XwE9M1ghLNV7IPxivDj1QzkuwEI0yVM7yQD9dYlwOBqLBwtIujmO4QfLYw7q6FwtI7raL5DhPHa0GgkrN0HYTQQpsfwbY0Gx6O+cH4kX2GcH104C+sbX1jhh7pzh57w4TE6qi+L6PHheMLxETvoIcJ4fCThxDpuBz2Eb2msV9WFi/idfFnEi9qFD733asAi/J7q0agoXL7LEViOMF7WKExXxx9C6YhWSvO/ivC+sqx0nAjD+3qEy/ccYvBQ6anywnUTeuguojW4MJ2+7xhKhj+VPRglhQ8NOQQPEYaS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F9rptFmbKe9VsNjWEqL9YpO2xAl/P6gvFE+MxyXKzBIaQnviN6MCF3gThW+tIkQHYxPqqIn0IagutO15zG/GIxGrV6JGQvve4o+pxyB6J3KzoL7Qthf8Aad+4nCs/H3VhfaE34w1E70TlSFGXyg6GuskBkP6FHZdQvuBO6jWR0xeqYsQahSi7UbI6ao1Eb1AZqcEKeR31TqIAefcYL1CO12zjeDEYPiiNMeDCdGeim2EJQbDH3oHIIQQDTlMIyDR1GcsRMZFRI85UEQveTH0AQjR8TiPqCIHBDFIkjeD4w9QiGK2in1gojd81Z0f8IARokFnHuINaUQMkuBZsgxTGVBCFJuFX0ZqE1HvfGFcn6YbgEJ7iwxNiEHivUiVQaUDVohiMp/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/

Image scrolling on hover

I want to make an image inside div to scroll down on hover. And that part is working.
Also, I need to make that it scroll longer if the image is longer and because of that I was trying to use calc inside of transition, but it is not working.
Here is my code:
.preview {
position: relative;
width: 75%;
height: 90vh;
overflow: hidden;
border: 1px solid red;
background-color: transparent;
}
.previewimg {
width: 100%;
height: 100%;
top: 0;
background-image: url(https://www.n2odesigns.com/wp-
content/uploads/Projema-Website-Preview-2016.jpg);
background-repeat: no-repeat;
background-size: 100% auto;
background-position-y: 0;
transition: all calc(0.02s * height) ease-in-out;
}
.previewimg:hover {
background-position-y: 100%;
height: 100%;
transition: all calc(0.02s * height) ease-in-out;
}
<div class="preview">
<div class="previewimg"></div>
</div>
If there is some other better way to do this I can use it too.
Ok to do this you need it to be an image only not a background image, to do this transition duration based on height functionality, please use the below code.
$('.previewimg').css("transition", "transform " + 0.02 * $('.previewimg').height() + "s ease");
.preview {
position: relative;
width: 75%;
height: 300px;
overflow: hidden;
border: 1px solid red;
background-color: transparent;
}
.preview .previewimg {
width: 100%;
height: auto;
transform: translateY(0px);
}
.preview:hover .previewimg {
transform: translateY(calc(-100% + 300px));
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="preview">
<img class="previewimg" src="https://www.n2odesigns.com/wp-content/uploads/Projema-Website-Preview-2016.jpg"/>
</div>
If you are accepting JS as a solution then here is a code you can add without changing your HTML/CSS structure :
function getHeight(url) {
console.log(url);
var img = new Image();
img.src = url;
return 0.002*parseInt(img.height);
}
var e =$(".previewimg");
var tr = "all "+getHeight(e.css("background-image").replace(/^url\(['"](.+)['"]\)/, '$1'))+"s ease-in-out";
console.log(tr);
e.css('transition',tr);
.preview {
position: relative;
width: 75%;
height: 90vh;
overflow: hidden;
border: 1px solid red;
background-color: transparent;
}
.previewimg {
width: 100%;
height: 100%;
top: 0;
background-image: url(https://www.n2odesigns.com/wp-content/uploads/Projema-Website-Preview-2016.jpg);
background-repeat: no-repeat;
background-size: 100% auto;
background-position-y: 0;
}
.previewimg:hover {
background-position-y: 100%;
height: 100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="preview">
<div class="previewimg"></div>
</div>
You don't actually use javascript for it.
it's codepen : codepen.io or it's the css code for you code:
.preview {
width:300px;
height:300px;
overflow: hidden;
}
.previewimg{
width: 100%;
height: 100%;
background-repeat: no-repeat;
background-size: cover;
background-image: url(https://source.unsplash.com/500x1500/);
transition: background-position 2s ease-out;
}
.preview:hover .previewimg{
background-position: 0 100%;
}
you can add other body elements with the styles classes name. And it make a boxes that when we hover the logo is changed. The logo is changes on hover.
*{
box-sizing: border-box;
}
.logoses{
text-align: center;
list-style: none;
}
.logoses .logo{
width: 178px;
height: 75px;
background:
url('G:/touqeer/amp-landing-pages/assets/images/clients_logo.png') center top no-repeat;
margin: 0 2px 8px;
border: 1px solid #e0e0e0;
display: inline-block;
vertical-align: middle;
transition: all .4s ease-in;
}
#amara{
background-position: 5px -125px;
}
#amara:hover{
background-position: 5px 0px;
}
#ge{
background-position: -1486px -125px;
}
#ge:hover{
background-position: -1486px -2px;
}
#nuance{
background-position: -489px -124px;
}
#nuance:hover{
background-position: -489px -1px;
}
#gilson{
background-position: -329px -123px;
}
#gilson:hover{
background-position: -329px 0px;
}
#pcs_wireless{
background-position: -824px -125px;
}
#pcs_wireless:hover{
background-position: -824px -2px;
}
#herbalife{
background-position: -161px -123px;
}
#herbalife:hover{
background-position:-161px 0px;
}
#pcf{
background-position: -659px -125px;
}
#pcf:hover{
background-position: -659px -2px;
}
#seimens{
background-position: -991px -125px;
}
#seimens:hover{
background-position:-991px -2px;
}
#melesta_games{
background-position: -1156px -124px;
}
#melesta_games:hover{
background-position: -1156px 1px;
}
#samsung{
background-position: -1324px -123px;
}
#samsung:hover{
background-position: -1324px 0px;
}
.center_pd{
padding: 75px 0px;
}
.text_bottom{
margin: 0px 0px 60px 0px;
}
.center_text{
text-align: center;
}
.header{
margin: 0px 0px 20px 0px;
}
h2{
font-size: 30px ;
font-weight: 400;
color: #393939;
}
.prg{
font-size: 16px;
color: #333;
font-family: Open Sans;
}

border-radius gradient with transparent background

I have this simple CSS spinner, here:
html {
background: black;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
#keyframes k__common-spin-cw {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
.wd-spinner {
height: 30px;
width: 30px;
border-style: solid;
border-color: rgba(255, 255, 255, 0.15);
border-width: 2px;
border-radius: 100%;
border-top-color: #00ba8c;
-webkit-animation: k__common-spin-cw 700ms linear infinite;
animation: k__common-spin-cw 700ms linear infinite;
}
<div class="wd-spinner"></div>
Is it possible to have a gradient border with border-radius, and instead of having the tail of the highlighted border-top just abruptly end, make it a nice gradient fade, while also keeping the background transparent?
I have removed the animation and increased the size to make the effect more easily visible.
With a pseudo, I have added a shadow of the same color than the border to create the fade.
Hover on the div and the overflow hidden will be applied, setting the final effect
html {
background: black;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.wd-spinner {
height: 200px;
width: 200px;
border-radius: 100%;
position: relative;
}
.wd-spinner:hover {
overflow: hidden;
}
.wd-spinner:after {
content: "";
position: absolute;
height: 196px;
width: 196px;
border-style: solid;
border-color: rgba(255, 255, 255, 0.15);
border-width: 2px;
border-radius: 100%;
border-top-color: #00ba8c;
}
.wd-spinner:before {
content: "";
position: absolute;
height: 196px;
width: 196px;
top: 2px;
left: 2px;
border-radius: 100%;
box-shadow: -40px -40px 70px -22px #00ba8c;
}
<div class="wd-spinner"></div>

CSS zoom effect background hover

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>

Resources