I'm working on an app that seems to be using CSS overlays. I have a basic understanding of CSS but not an expert.
In the style.css I see two classes:
.modal-wrapper {
height: 100%;
width: 100%;
position: fixed;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.8);
z-index: 15000;
opacity: 1;
visibility: visible;
transition: All 0.2s ease-in-out;
-webkit-transition: All 0.2s ease-in-out;
-moz-transition: All 0.2s ease-in-out;
-o-transition: All 0.2s ease-in-out; }
.modal-wrapper.hide {
opacity: 0;
visibility: hidden; }
I'm using this in a React app and I need help with closing the overlay.
I simply render a component and set its isShown property to true and I'm able to open up the overlay.
However, I'm not sure about how to close it. Even if I set the isShown value to false in my redux store, the overlay still sits there.
I'd appreciate some help with closing the overlay. Thanks.
hope it helps!
.modal-wrapper.hide {
visibility: hidden;
opacity: 0;
width: 0;
height: 0;
}
I suggest setting your z-index to -1 or something lower, as the overlay will sit-on-top of other elements.
.modal-wrapper.hide {
opacity: 0;
visibility: hidden;
z-index: -1;
}
Please try this code
HTML
<div class="modal-wrapper"></div>
<div class="modal-wrapper hide"></div>
CSS
.modal-wrapper {
height: 100%;
width: 100%;
position: fixed;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.8);
z-index: 15000;
opacity: 1;
visibility: visible;
transition: All 0.2s ease-in-out;
-webkit-transition: All 0.2s ease-in-out;
-moz-transition: All 0.2s ease-in-out;
-o-transition: All 0.2s ease-in-out; }
.modal-wrapper.hide {
opacity: 1;
visibility: visible;
width: 20px;
cursor:pointer;
background-color: transparent;
margin: 10px 20px;
height: 20px;
}
.modal-wrapper.hide:after, .modal-wrapper.hide:before {
content: "";
width: 2px;
height: 20px;
background: #fff;
display: inline-block;
transform: translatex(-1px) rotate(45deg);
}
.modal-wrapper.hide:before{
transform: translatex(0) rotate(-45deg);
}
Jsfiddle
Related
Just as a quick overview - I have purchased a theme for WordPress that has custom in-built animations for it's main menu (starts off large and transparent, and then on scroll, it becomes thinner with a solid colour background).
I've been trying for the past few days to simply set the scroll menu as the permanent menu and get rid of the animation, but I'm not having all that much luck with it, so any help would be really appreciated.
Css:
/* 2. Header
===============================================================*/
.wsmenucontainer header.topheader {
background: #222;
}
.wsmenucontainer header.topheader {
left: 0;
padding: 1rem 0 12rem;
position: fixed;
top: 0;
width: 100%;
z-index: 1000;
transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-webkit-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
}
.wsmenucontainer header.topheader .header-image {
background: #222;
height: 100%;
left: 0;
opacity: 1;
overflow: hidden;
position: absolute;
top: 0;
width: 100%;
}
.wsmenucontainer header.topheader .header-image img {
left: 0;
opacity: 0.5;
position: absolute;
top: 50%;
width: 100%;
transform: translateY(-50%);
-moz-transform: translateY(-50%);
-webkit-transform: translateY(-50%);
-o-transform: translateY(-50%);
transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-webkit-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
}
header.topheader.scroll {
background: #222;
padding: 0;
}
header.topheader.scroll .header-image img {
opacity: 0;
}
.noHeadImage header.topheader {
padding: 1rem 0;
background:transparent;
}
.noHeadImage .header-image {
display:none;
}
.noHeadImage header.topheader.scroll {
background: #222;
padding: 0;
}
main section {
padding: 8rem 0;
}
main section#single-class{
padding: 0;
}
Jordy i help you, can you provide a Theme preview link?
You can either remove or comment transition css. Hope it gelps
.wsmenucontainer header.topheader {
left: 0;
padding: 1rem 0 12rem;
position: fixed;
top: 0;
width: 100%;
z-index: 1000;
//comment this area to remove transition
/* transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-webkit-transition: all 0.3s ease;
-o-transition: all 0.3s ease; */
}
.wsmenucontainer header.topheader .header-image img {
left: 0;
opacity: 0.5;
position: absolute;
top: 50%;
width: 100%;
transform: translateY(-50%);
-moz-transform: translateY(-50%);
-webkit-transform: translateY(-50%);
-o-transform: translateY(-50%);
//comment this area to remove image transition
/* transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-webkit-transition: all 0.3s ease;
-o-transition: all 0.3s ease; */
}
To fix it, you can add a custom css in your theme (css custom area) or via plugin (https://it.wordpress.org/plugins/wp-add-custom-css/)
Your custom code:
.wsmenucontainer header.topheader{
transition: none; */
-moz-transition: none;
/* -webkit-transition: none; */
-o-transition: none;
}
I'm using a template for my blog but I want to vertically align the text on the slider. I've tried changing the padding but then it's not centered while on mobile. Also when I change the top value from 0 to a percentile value it doesn't work.
.sora-slide .ty-thumb-bonos {
position: relative;
float: left;
margin: 0!important;
width: 100%;
height: 560px;
overflow: hidden;
display: block;
vertical-align: middle;
}
.sora-slide .sora-slide-con {
position: absolute;
left: 0;
right: 0;
margin: auto;
bottom: 0;
top: 0;
width: 100%;
padding: 20px 10px;
z-index: 2;
box-sizing: border-box;
text-align: center;
max-width: 460px;
display: table;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-ms-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
You could add this to .sora-slide .sora-slide-con
transform: translateY(-50%);
top: 50%;
and replace
margin: 15% auto;
with
margin: 0 auto;
This should do it, if I understand you.
Full css:
.sora-slide .sora-slide-con {
position: absolute;
left: 0;
right: 0;
margin: 0 auto; /* <- 0 auto */
bottom: 0;
top: 50%; /* <- 50% instead of 0 */
width: 100%;
padding: 20px 10px;
z-index: 2;
box-sizing: border-box;
text-align: center;
max-width: 460px;
display: table;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-ms-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
transform: translateY(-50%); /* <- transformY -50% */
}
To understand why I added transform and top, see this anwser on SO: https://stackoverflow.com/a/40530404/6773269 by
Andrew Bone.
He explained it very well.
Or like aldo.roman.nurena said:
TL;DR top applies 50% from page/container height, transform: translateY applies -50% from own element height.
I'm trying to do a basic ease out transition on a panel with a background image. I'm wanting it to fade to background color on hover. I've tried using various transitions non of which are working. I've tried (which i thought would work):
transition:background-image 0.2s ease-in-out;
.panel {
width:200px;
height:200px;
background:#000 url("https://cdn.pixabay.com/photo/2016/03/28/12/35/cat-1285634_1280.png") no-repeat center center / cover;
transition:background-image 0.2s ease-in-out;
}
.panel:hover {
background:#000;
transition:background-image 0.2s ease-in-out;
}
<div class="panel"></div>
You can use this code:
Demo is here: https://output.jsbin.com/yadiwoviwe
.panel {
position: relative;
background: rgba(0,0,0,0) url(https://cdn.pixabay.com/photo/2016/03/28/12/35/cat-1285634_1280.png) no-repeat center center / cover;
width:200px;
height:200px;
transition: background-color 0.2s ease-in-out;
}
.panel:hover {
background-color: rgba(0,0,0,.5);
}
.panel:before {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
background-color: inherit;
content: ' ';
}
Unfortunately, you can't do this in this way.
The reason is that you're trying to animate the background-image property - a property that isn't animatable.
Instead, you can use a cool little trick that uses a pseudo-element to create the background image instead:
.panel {
width: 200px;
height: 200px;
position: relative;
background: pink;
}
.panel::after {
content: "";
position: absolute;
pointer-events: none;
background: url(https://unsplash.it/200) center center no-repeat;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1;
will-change: opacity;
transition: opacity .1s ease-out;
}
.panel:hover::after {
opacity: 0.5;
}
<div class="panel"></div>
Inspired by this cool little article on CSSTricks
Alternatively, you can manipulate the opacity of the image.
.panel {
width: 200px;
height: 200px;
background: #000;
position: relative;
color: white;
text-align: center;
}
.panel:after {
content: "";
background-image: url('https://cdn.pixabay.com/photo/2016/03/28/12/35/cat-1285634_1280.png');
background-size: 200px 200px;
position: absolute;
top: 0;
left: 0;
width: 200px;
height: 200px;
opacity: 1;
transition: opacity 0.2s ease-in-out;
}
.panel:hover:after {
opacity: 0;
}
<div class="panel"><h1>Text</h1></div>
Outdated answer, transition with image working currently with CSS.
-webkit-transition: all 1s ease-out;
-moz-transition: all 1s ease-out;
-o-transition: all 1s ease-out;
transition: all 1s ease-out;
background-image instead of 'all' and you'll see.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
My CSS transitions aren't working. The hover appears but the easing transitions are not working. Please help, thanks!
<div class="6u overlay">
<a href="astronomy.html" class="image full l">
<img src="images/thumbs/1.jpg" title="Astronomy Nights Branding UI/UX" alt="Astronomy Nights Branding UI/UX" />
<div class="after">Astronomy Nights<br/><span style="font-size:0.5em; font-style:italic; letter-spacing:1px;">Branding, UI/UX</span></div></a>
</div>
CSS
.overlay {
position: relative; }
.overlay .after {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: none;
color: #000000; font-size:1.5em; font-weight:400; letter-spacing:-1px; padding-top:3em; }
.overlay:hover{ -moz-transition: all 0.6s ease-in-out;
-webkit-transition: all 0.6s ease-in-out; -o-transition: all 0.6s
ease-in-out; -ms-transition: all 0.6s ease-in-out; transition: all
0.6s ease-in-out;
}
.overlay:hover .after {
display: block;
background: rgba(255, 255, 255, .9);
}
You should use visibility: hidden instead of disply:noneand the transition must be in .after not overlay
.overlay {
position: relative;
}
.overlay .after {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
visibility: hidden;
opacity:0;
color: #000000;
font-size:1.5em;
font-weight:400;
letter-spacing:-1px;
padding-top:3em;
}
.overlay:hover .after {
visibility: visible;
opacity:1;
background: rgba(255, 255, 255, .9);
-moz-transition: all 0.6s ease-in-out;
-webkit-transition: all 0.6s ease-in-out;
-o-transition: all 0.6s ease-in-out;
-ms-transition: all 0.6s ease-in-out;
transition: all 0.6s ease-in-out;
}
Demo here: https://jsfiddle.net/IA7medd/850hhcqd/
Well, to start off with, CSS3 transitions can't animate a display: none property. If you want the overlay to fade in, I'd use the CSS opacity property. Set opacity: 0; on the .overlay .after first, then in the .overlay:hover .after set the opacity to 1. That'll let the overlay animate in and out without hiding it immediately like display: none would do.
Here's your CSS (formatted and edited to work). The overlay element is the only thing that changes opacity, and I moved stuff around to make more sense.
Demo here: http://codepen.io/anon/pen/dMBJML
.overlay {
position: relative;
}
.overlay:hover {
opacity: 1;
}
.overlay .after {
opacity: 0;
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
color: #000000;
font-size:1.5em;
font-weight:400;
letter-spacing:-1px;
padding-top:3em;
transition: all 0.6s ease-in-out;
}
.overlay:hover .after {
opacity: 1;
background: rgba(255, 255, 255, .9);
}
I wrote some css codes but was told that I need to improve/optimize them, is there any idea? Thanks!
.box-popup {
opacity: 0;
position: absolute;
color: ‘#ccc’;
z-index: 1000;
top: -72px;
left: 165px;
width: 250px;
height: 200px;
background-color: ‘#ccc’;
padding: 30px 50px 40px 50px;
border-radius: 3px;
transition: opacity 400ms ease-in-out;
-moz-transition: opacity 400ms ease-in-out;
-webkit-transition: opacity 400ms ease-in-out;
}
Here is the reviewed code: (check the comments)
.box-popup {
opacity: 0;
position: absolute;
color: #ccc; /* removed quotes */
z-index: 1; /* try not to use higher z-index values unnecessarily */
top: -72px;
left: 165px;
width: 250px;
height: 200px;
background-color: #ccc; /* removed quotes or use currentColor if the color is same as of color property */
padding: 30px 50px 40px 50px;
border-radius: 3px;
transition: opacity .4s ease-in-out; /* used 'seconds' unit just to make it shorter */
-moz-transition: opacity .4s ease-in-out;
-webkit-transition: opacity .4s ease-in-out;
}