css transition not working on dialog box - css

I am trying to figure out why the fade in and out of a dialog box in this code is not working properly.
What I'm trying to do is having a fade in and out on click. But I am trying to do this fade in/out with CSS only though.
When i remove manually the class "active" in the console the effect works, but not when I actually click on the link (to open the dialog box).
This is my code
CSS:
.modal {
display: block;
overflow: auto;
overflow-y: scroll;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 99;
-webkit-overflow-scrolling: touch;
outline: 0;
background-image: url('pixel.png');
opacity: 1;
}
.modal-dialog {
max-width: 600px;
background-color: white;
z-index: 99;
min-height: 200px;
opacity: 0;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
.modal-dialog .active {
opacity: 1;
background-color: #ffffff;
border: 1px solid #999;
-webkit-background-clip: padding-box;
-moz-background-clip: padding-box;
background-clip: padding-box;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
My JS (just in case):
$('body').on('click', '[data-modal]', function (e) {
e.preventDefault();
$('body').addClass('modal-open');
$('body').append("<div class='modal'></div>").addClass('active');
$('.modal').append("<div class='modal-dialog'></div>")
$('.modal-dialog').html("<div class='modal-inner generic-content'></div>").addClass('active');

Transition needs numeric value in order to set steps in between 2 rules statement.
You should use : opacity instead display:
http://jsfiddle.net/bJz7R/1/
$('a.click-me').click(function(){
$('#open').css('opacity','1');
});
and replace in CSS:
display:none;
by
opacity:0;

Related

CSS - disabling a menu animation

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 have a transition for a label on input focus, is there a way to make the transition go backward on blur?

Consider the following fiddle code
<div class="my-wrapper">
<input type="text"
placeholder="placeholder." >
<label >Press enter to save</label>
</div>
.my-wrapper {
input {
width: 200px;
height: 3em;
}
input:focus + label{
right: 20px;
opacity: 1;
color: #D3D3D3;
}
label{
line-height: 40px;
position: absolute;
right: 160px;
-moz-transition: 0.3s right ease;
-ms-transition: 0.3s right ease;
-o-transition: 0.3s right ease;
-webkit-transition: 0.3s right ease;
transition: 0.3s right ease;
z-index: 0;
opacity: 0;
}
}
I am seeing the forward transition on focus, I thought on blur the transition would go backwards, but I don't see it, can someone give me a hint on what I did wrong?
You can keep this simple by using transform instead of absolute values
.my-wrapper input {
width: 200px;
height: 3em;
}
.my-wrapper input:focus+label {
transform: translateX(0);
opacity: 1;
color: #D3D3D3;
}
.my-wrapper label {
position: absolute;
right: 10px;
line-height: 40px;
transform: translateX(-20px);
transition: 0.3s all ease;
z-index: 0;
opacity: 0;
}
<div class="my-wrapper">
<input type="text" placeholder="placeholder.">
<label>Press enter to save</label>
</div>
You have given transition: 0.3s right ease which will apply only to right property and not for opacity.
Change the transition property to transition: 0.3s all ease and the effect fades out smoothly on blur.
JsFiddle link

How to apply transform and transition effect on a div

I was practicing css on an example i found. I tried to show the submenu above the nav with transition effects. I can change the position of the submenu on hover :
nav li:hover .menu-sub {
display: block;
transform: translateY(-100%);
}
I also modified the code to add a transition effect:
.menu-sub {
position: absolute;
left: 0;
background: #444;
width: 100%;
display: none;
color: #fff;
padding: 2em;
-webkit-transition: -webkit-transform 1.5s ease;
-moz-transition: -moz-transform 1.5s ease;
-o-transition: -o-transform 1.5s ease;
transition: transform 1.5s ease;
}
The position changed but I don't see any transition effect at all. What am i doing wrong ?
Please modify the transition to shown below, it was written wrong.
.menu-sub {
position: absolute;
left: 0;
background: #444;
width: 100%;
opacity:0;
overflow:hidden;
box-sizing:border-box;
height:0px;
color: #fff;
-webkit-transition: opacity 1.5s ease-out;
-moz-transition: opacity 1.5s ease-out;
-o-transition: opacity 1.5s ease-out;
transition: opacity 1.5s ease-out;
}
Transition does not work with display, instead use the below effect.
Codepen Demo
Where we can toggle the height from 0px to auto(full height) and opacity from 0(invisible) to 1(visible). You can see that we only see the animation on opacity, this will produce the best effect.
Use visibility:hidden then visible
display: none disables it in the active DOM and such elements with this CSS can't be selected for stuffs like animations.
.menu-sub {
position: absolute;
left: 0;
background: #444;
width: 100%;
visibility: hidden;
color: #fff;
padding: 2em;
transition: transform 1.5s ease;
}
nav li:hover .menu-sub {
visibility: visible;
transform: translateY(-100%);
}

Background color not changing 'smoothly'. CSS transitions not working [closed]

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);
}

drop-down menu closing issue in wordpress?

I already succeed to added the transition effect when hover the cursor to drop-down menu (click the "M" logo) in my own wordpress theme but when the cursor being away from drop-down menu don't show the transition effect when closing. You can check out my own theme on this link for further info.
Here drop-down css style:
.dropdown-menu {
border-bottom-right-radius: 77px;
border-bottom-left-radius: 77px;
/* background: url(img/submenu.png) no-repeat scroll right/ 91% 100%; */
position: absolute;
height:0;
top: 100%;
left: 0;
z-index: 1000;
display: none;
float: left;
min-width: 153px;
padding: 1px 0;
margin: 2px 0 0 0;
list-style: none;
font-size: 14px;
text-align: center;
background-color: transparent!important;
border: 1px solid #ccc;
border: 1px solid rgba(0,0,0,0.15);
background-clip: padding-box;
opacity: 0;
top: 35px;
visibility: hidden;
-webkit-transition:height 300ms ease-in;
-moz-transition:height 300ms ease-in;
-ms-transition: height 300ms ease-in;
-o-transition:height 300ms ease-in;
transition:height 300ms ease-in;
overflow: hidden;
}
.navbar-nav li:hover .dropdown-menu {
opacity: 1;
top: 105px;
visibility: visible;
height:300px;
}
So How I can add the transition effect when drop-down menu closing?
Instead of transitioning only the height you could try
-webkit-transition: all 300ms ease-in;
-moz-transition: all 300ms ease-in;
-ms-transition: all 300ms ease-in;
-o-transition: all 300ms ease-in;
transition: all 300ms ease-in;

Resources