Flickering backdrop filter blur on scaling - css

I have a simple card which zooms on hovering. The card text has a backdrop blur. When I hover the card, the transition goes smoothly, but the bottom edges of the text container seem to flicker.
.card{
width: 200px;
height: 250px;
border-radius: 10px;
transition: transform 0.5s;
display: flex;
flex-direction: column;
justify-content: flex-end;
overflow: hidden;
background-image: url("https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg");
margin: 50px;
transition: transform 0.5s;
will-change: transform;
}
.card:hover{
transform: scale(1.05);
}
.card-details{
background-color: rgb(255 255 255/60%);
backdrop-filter: blur(5px);
padding: 15px;
font-size: 30px;
}
<div class="card">
<div class="card-details">
Lorem Ipsum
</div>
</div>
Any suggestions?

You can try to using border: 2px solid transparent; for the entire card, this will prevent flickering, but you will get a border instead of a flickering effect. If you try to change the color of the border, you will get back a flikering effect.
Another way, more complicated, you will need to add a pseudo-element to the card-details class, then move backdrop-filter, background-color to the pseudo-element.
UPDATED
It also works with padding: 2px instead of border: 2px solid transparent;
body {
display: flex;
justify-content: center;
gap: 1rem;
}
.card,
.card2,
.card3 {
width: 200px;
height: 250px;
border-radius: 10px;
display: flex;
flex-direction: column;
justify-content: flex-end;
overflow: hidden;
background-image: url('https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg');
/* margin: 25px; */
transition: transform 0.5s;
will-change: transform;
}
.card2 {
border: 2px solid transparent; /* trick */
}
.card:hover,
.card2:hover,
.card3:hover {
transform: scale(1.05);
}
.card-details {
background-color: rgb(255 255 255/60%);
backdrop-filter: blur(5px);
padding: 15px;
font-size: 30px;
}
.card-details3 {
padding: 15px;
border-radius: 0 0 8px 8px;
border: 2px solid transparent; /* trick */
font-size: 30px;
position: relative;
}
.card-details3::after {
content: '';
position: absolute;
inset: 0;
background-color: rgb(255 255 255/60%);
backdrop-filter: blur(5px);
border-radius: inherit;
z-index: -1;
}
<div class="card">
<div class="card-details">Lorem Ipsum</div>
</div>
<div class="card2">
<div class="card-details">Lorem Ipsum</div>
</div>
<div class="card3">
<div class="card-details3">Lorem Ipsum</div>
</div>

Related

sass animation did not work after adding a transition-timing function

i wanted to create a box with a border and inside it a small div, i wanted when i have a hover over the box the small div inside it will start to animate and but the animation did not start at all, so i deleted hover also the animation did not work in this case too,
here what i have tried:
<div class="row mb-4">
<div class="col col__animation">
<div id="object"></div>
</div>
</div>
Scss:
.col__animation{
display: flex;
border-radius: 1rem !important;
border: 1px solid #284876;
height: 200px !important;
align-items: center;
#object {
width: 40px;
height: 50px;
background: blueviolet;
margin-top: 2px;
margin-bottom: 1px;
margin-right: 3px;
}
&:hover{
#object{
transition: transform 1000ms;
transition-timing-function: ease-in-out;
}
}
}
I am trying to try many animations effects like making the box move to right and go back to initial position and many more animations
This should work
.col__animation {
display: flex;
border-radius: 1rem !important;
border: 1px solid #284876;
height: 200px !important;
align-items: center;
}
.col__animation #object {
width: 40px;
height: 50px;
background: blueviolet;
margin-top: 2px;
margin-bottom: 1px;
margin-right: 3px;
animation: mymove 3s infinite;
}
#keyframes mymove {
0% {
margin-left: 0px;
}
50% {
margin-left: calc(100% - 40px);
}
100% {
margin-left: 0px;
}
}
Codepen

3D-like hover effect on button

I'm trying to replicate this effect with pure CSS:
So far I've tried doing:
.parent {
height: 90vh;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.hoverable-element {
border: 0.1rem solid #000;
background: #fff;
padding: 1rem 2rem;
transform: translate(0, 0);
box-shadow: 0 0 0 #000;
transition:
box-shadow 200ms ease-out,
transform 200ms ease-out;
}
.hoverable-element:hover {
transform: translate(-0.5rem, -0.5rem);
box-shadow:
0.1rem 0.1rem 0 #000,
0.2rem 0.2rem 0 #000,
0.3rem 0.3rem 0 #000,
0.4rem 0.4rem 0 #000,
0.5rem 0.5rem 0 #000;
}
<div class="parent">
<button class="hoverable-element">Hoverable Button</button>
</div>
But this method repeats a lot of unnecessary code, as well as not properly doing what I intended.
I want the button "shadow" or hover-effect-thingy to be bordered with a white background (as shown in the image). Other than that I'm clueless as to where to start
here is an idea with pseudo element and skew transformation:
.parent {
height: 90vh;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.hoverable-element {
border: 1px solid #000;
background: #fff;
padding: 1rem 2rem;
position: relative;
transition: transform 0.5s;
}
.hoverable-element::before,
.hoverable-element::after {
content: "";
position: absolute;
border: inherit;
transition: inherit;
}
.hoverable-element::before {
height: 1rem;
top: 100%;
left: -1px;
right: -1px;
transform-origin: top left;
transform: skewX(45deg) scaleY(var(--s, 0));
}
.hoverable-element::after {
width: 1rem;
left: 100%;
top: -1px;
bottom: 0;
border-bottom:none;
transform-origin: bottom left;
transform: skewY(45deg) scaleX(var(--s, 0));
}
.hoverable-element:hover {
transform: translate(-0.5rem, -0.5rem);
--s: 1;
}
<div class="parent">
<button class="hoverable-element">Hoverable Button</button>
</div>

Box-shadow on div with border-radius 50% visible on Mozilla and not Chrome / Edge

I have a little CSS issue and I have no idea why :
As you can see, Edge and Chrome are "normal" but on Mozilla the shadow is visible and I have no idea why...I checked on canaiuse (https://caniuse.com/#feat=css-boxshadow) and I didn't see compatibility problem, someone have an idea why?
Here is the html / css of this part :
HTML
My Doctype : <!DOCTYPE html>
<div class="myclass col-5">
<i class="fas fa-camera-retro" aria-hidden="true"></i>
<i class="fas fa-images" aria-hidden="true"></i>
<i class="fas fa-cogs" aria-hidden="true"></i>
</div>
CSS - SASS (here is my .scss before I compile)
.myclass {
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
align-items: center;
padding-right: 0;
#include position(absolute, 0, 0, null, null);
a.btn {
height: 30px;
width: 30px;
border-radius: 50%;
text-align: center;
padding: 0;
position: relative;
transition: all .2s ease-out;
box-shadow: 0 0 0 0 $grey-dark;
z-index: 50;
&:hover {
transform: translate(2px, -2px);
box-shadow: -2px 2px 0px 0px $grey-dark;
}
.fa-cogs,
.fa-camera-retro,
.fa-images {
color: $white;
}
svg {
display: block;
margin: 0 auto;
#include vertical-align();
}
}
}
I tried to remove the data-balloon part of my link just to see if the balloon.css I the problem but nothing change
PS : if you need the CSS after I compile tell me, but you should see what I do with the code bellow
EDIT : Here is a snippet where you can see the problem if you open it on MOZILLA
div {
flex-flow: row nowrap;
justify-content: space-between;
align-items: center;
padding-right: 0;
}
div a {
display: inline-block;
height: 30px;
width: 30px;
border-radius: 50%;
text-align: center;
padding: 0;
position: relative;
transition: all .2s ease-out;
box-shadow: 0 0 0 0 black;
z-index: 50;
background: orange;
}
div a:hover {
transform: translate(2px, -2px);
box-shadow: -2px 2px 0px 0px black;
}
<div>
<a></a>
<a></a>
<a></a>
</div>
I tested your code and its working fine. I don't see any box-shadow issue here...However if issue is there you can just set box-shadow color to transparent at normal state and change it on :hover
div {
height: 30px;
width: 30px;
border-radius: 50%;
text-align: center;
padding: 0;
position: relative;
transition: all .2s ease-out;
box-shadow: 0 0 0 0 transparent;
z-index: 50;
background: orange;
}
div:hover {
transform: translate(2px, -2px);
box-shadow: -2px 2px 0px 0px grey;
}
<div></div>

Lock a div in place after you have selected it

So I have the hover state figured out. I'd like to keep the card at it's translated stated once I click on it though. I've tried using pseudo class :focus and :active but it didn't work. Or I'm just not putting the right values in.
$('.wrapper').on('click', function() {
$(this).addClass('active');
});
.wrapper:hover {
transform: translateY(5px);
}
.wrapper:active {
transform: translateY(5px);
position: fixed;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<div class="paper">
<img src="https://www.jbhifi.com.au/FileLibrary/ProductResources/Images/216422-M-LO.jpg">
<div class="poster">
<h2>Featured</h2>
<h1>Big Baby Swing</h1>
<p>Does he look like hes stupid. Did he drive well? No. Then is he stupid? He's a good kid that's like the devil behind a wheel. That's all you need to know about him..</p>
More
</div>
</div>
<div class="space"></div>
</div>
codepen to my question
You assign a active class on click so .wrapper.active instead of .wrapper:active should work
You missed jquery cdn and add some css following if you need to get back use toggleClass.
.wrapper.active{
transform: translateY(5px);
}
.wrapper.active div a.button{
width:auto;
font-size: 0.8rem;
background-color: #29426d;
box-shadow: none;
}
$('.wrapper').on('click', function() {
$(this).addClass('active');
// You can use here toggleClass also
});
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
background: #2c3e50;
font-family: 'Montserrat', sans-serif;
font-size: 14px;
}
/* this centers the card in the middle of any browser */
body {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
align-items: center;
align-content: center;
background-color: #D7D7DD;
}
/* You can rename this .wrapperCard or what ever you may have used. The important thing to notice is the z-index relative to the .papaer div in order for this to work. In the HTML document .space which contains the gradient at the bottom is out side of .paper that holds the information. */
.wrapper {
margin: 0;
padding: 0;
height: auto;
width: auto;
transition: 1s ease;
cursor: pointer;
z-index: 98;
}
.wrapper:hover{
transform: translateY(5px);
}
.wrapper.active{
transform: translateY(5px);
}
.wrapper.active div a.button{
width:auto;
font-size: 0.8rem;
background-color: #29426d;
box-shadow: none;
}
.wrapper:hover div a.button{
width:auto;
font-size: 0.8rem;
background-color: #29426d;
box-shadow: none;
}
/* This calls onto the div.paper on hover and looks for div.space, if you take a way div.space your gradient will not longer dissapear on hover. */
.wrapper:hover div.space{
transform: translateY(-7px);
z-index:-1;
}
/* This is the div that contains all of the informoation, to be noted. The div is set to a specific height of 41, it basically reaches to the bottom of the MORE button. The reason being is so I can hide the gradient which is the div space, placed all the way at the bottom with a z-index of -1. If you take out the height in div.paper you will see why I made the card a particular size, so keep that in mind when you are transfering the gradient code onto the cards for NASCA. */
.paper{
font-family: 'Titilium Web', sans-serif;
display: flex;
flex-wrap: wrap;
align-items: center;
align-content: center;
margin: 0 auto;
padding: 0;
max-width: 300px;
min-width: 300px;
background: white;
text-align: justify;
z-index: 99;
}
a.image{
flex: 1;
text-align: none;
font-size: none;
text-decoration: none;
color:none;
transition: none;
padding:0;
margin: 0;
height: auto;
}
a.image:hover{
color:none;
border-bottom:none;
text-align: none;
box-shadow: none;
transform: none;
}
.poster{
flex: 1;
height: auto;
}
h2{
flex: 1;
font-size: .55rem;
color: #A0A6AB;
letter-spacing: 2px;
text-transform: uppercase;
text-align: center;
font-family: $sans-serif;
font-weight: 500;
margin-bottom: 10px;
}
h1{
flex: 1;
display: flex;
justify-content: center;
margin-top:1rem;
font-weight:bolder;
letter-spacing: normal;
font-kerning: 1rem;
transition: 0.5s ease;
color: #29426d;
}
h1:hover{
transform: translateX(2px);
}
p{
flex: 1;
padding: 1rem 1rem;
color:#333333;
}
a.button{
position: relative;
display: flex;
justify-content: center;
cursor: pointer;
text-transform: uppercase;
text-decoration: none;
font-size: 0.8rem;
line-height: 20px;
letter-spacing: .06rem;
font-weight: bold;
color: white;
background: #e44d6e;
margin: 0 auto;
padding: 0.5rem 1rem;
width: auto;
transition: 1s ease;
}
/* To be noted, the top selector is set to -4px because the gradient is too strong initially, pulling it up some makes it less harsh. */
.space{
flex: 1;
position: relative;
padding: 0;
margin: 0;
left: 0;
bottom: 0;
width:100%;
height: 1rem;
background: grey;
background: -webkit-linear-gradient(#333333 -290%, transparent 100%);
background: -o-linear-gradient(#333333 -290%, transparent 100%);
background: -mox-linear-gradient(#333333 -290%, transparent 100%);
background: linear-gradient(#333333 -290%, transparent 100%);
transition: 1s ease;
z-index: -1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<div class="paper">
<img src="https://www.jbhifi.com.au/FileLibrary/ProductResources/Images/216422-M-LO.jpg">
<div class="poster">
<h2>Featured</h2>
<h1>Big Baby Swing</h1>
<p>Does he look like hes stupid. Did he drive well? No. Then is he stupid? He's a good kid that's like the devil behind a wheel. That's all you need to know about him..</p>
More
</div>
</div>
<div class="space"></div>
</div>
</body>

Thumbnail hover scaling within thumbnail size

I am trying to get a scale effect when I hover over a thumb, as in this Codepen example (first thumb, the Lily effect):
http://codepen.io/intermedion/pen/BQVJEx
I modified the above example to remove the figure/figcaption, and I used a flexbox layout for the thumb grid, see this pen:
http://codepen.io/intermedion/pen/dOKrWQ?editors=1100
<!-- HTML -->
<div class="wrap">
<div class="row">
<div>
<a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-1.jpg">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-1.jpg">
</a>
</div>
<div>
<a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-3.jpg">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-3.jpg">
</a>
</div>
</div>
</div>
/* CSS */
.row {
display: flex;
flex-flow: row wrap;
padding: 0 5px;
font-size: 0;
}
.row div {
flex: auto;
width: 160px;
margin: 6px 12px;
}
.row div img {
width: 100%;
height: auto;
}
/*** EFFECTS ***/
.row img {
position: relative;
display: block;
min-height: 100%;
max-width: 100%;
}
.row img {
-webkit-transition: opacity 0.35s, -webkit-transform 0.35s;
transition: opacity 0.35s, transform 0.35s;
}
.row:hover img {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-transform: scale(1.15);
transform: scale(1.15);
}
I tried various options, including setting sizes on the thumbs, adding figure/figcaption - the thumbs scale, but over and beyond the thumbnail size, which is not what I want.
I am starting to suspect that it may be the flexbox layout that is causing the scaling beyond the rendered thumb size, but I am not sure.
Is there any way to do the scaling within the rendered thumb with a flexbox layout?
I think you forgot overflow:hidden for the div:
.row div {
flex: auto;
width: 160px;
margin: 6px 12px;
overflow: hidden;
}
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
ul {
list-style-type: none;
}
a:link { text-decoration: none; }
a:visited { text-decoration: none; }
a:hover { text-decoration: none;}
html {
background: #2b303b;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/*** LAYOUT ***/
.wrap {
max-width: 660px;
margin: 1.5em auto 1em auto;
padding: 10px 10px;
background: #2e333f;
background-color: rgba(32, 38, 52, 0.6);
background: #242B3A;
font-family: "PT Sans", "Helvetica Neue", Arial, sans-serif;
font-size: 100%;
color: rgba(127, 133, 147, 0.8);
border-radius: 5px;
-webkit-border-radius: 0px 0px 5px 5px;
-moz-border-radius: 0px 0px 5px 5px;
}
/*** GRID ***/
.row {
display: flex;
flex-flow: row wrap;
padding: 0 5px;
font-size: 0;
}
.row div {
flex: auto;
width: 160px;
margin: 6px 12px;
overflow: hidden;
}
.row div img {
width: 100%;
height: auto;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
/*** EFFECTS ***/
.row img {
position: relative;
display: block;
min-height: 100%;
max-width: 100%;
}
.row img {
-webkit-transition: opacity 0.35s, -webkit-transform 0.35s;
transition: opacity 0.35s, transform 0.35s;
}
.row div:hover img {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-transform: scale(1.15);
transform: scale(1.15);
}
/*** CAPTIONS ***/
/*
.grid figure {
position: relative;
float: left;
overflow: hidden;
margin: 10px 1%;
min-width: 300px;
max-width: 480px;
max-height: 360px;
width: 48%;
background: #3085a3;
text-align: center;
cursor: pointer;
}
*/
/*
.grid figure img {
position: relative;
display: block;
min-height: 100%;
max-width: 100%;
opacity: 0.8;
}
*/
<div class="wrap">
<div class="row">
<div>
<a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-1.jpg">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-1.jpg">
</a>
</div>
<div>
<a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-3.jpg">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-3.jpg">
</a>
</div>
</div>
</div>

Resources