Transition CSS effect

Transition is key when transitioning from one value to another based on an event.

Take a look at the visibility setting for an element:

.two {
  background-color: #9fa8da;
  position: absolute;
  visibility: hidden;
  transition: visibility 3ms ease-in;
}

When a button is clicked, the visibility is changed to 'visible'

.two-show {
   visibility: visible;
}

Unfortunately, there is no animation effect present.

Check out the Plnkr demo here:

http://plnkr.co/edit/4Fhb1Uj744BRwCDhebOP?p=info

Answer №1

Consider including the following in your .two{}:

-webkit-transition: opacity 25ms ease-in, -webkit-transform 3s;
-moz-transition: opacity 25ms ease-in;
-o-transition: opacity 25ms ease-in;

Is a duration of 25ms too quick?

Answer №2

To achieve the desired outcome, you can utilize the opacity property. Check out the updated version of your plunker with this new method implemented. In addition, I have extended the transition duration for a more noticeable effect.

.two {
  background-color: #9fa8da;
  position: absolute;
  opacity: 0;
  transition: opacity 3s ease-in;
}

.two-show {
  opacity: 1;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Integrate SVG into the dropdown menu without duplicating the SVG element

I have an SVG of a right arrow: <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"> <path d="M0 0h24v24H0V0z" fill="none"/> ...

Is there a way to override a LESS variable inside a mixin?

Currently, I am incorporating LESS into one of my projects and I have a requirement to establish different color schemes for various users. The project involves developing a portal where the color scheme should change based on the type of user logging in. ...

How can I reset a CSS position sticky element using JavaScript?

I have created a page where each section fills the entire screen and is styled using CSS position: sticky; to create a cool layered effect. Check it out here: https://codesandbox.io/s/ecstatic-khayyam-cgql1?fontsize=14&hidenavigation=1&theme=dark ...

Tips for positioning two elements side by side on a small screen using the Bootstrap framework

Greetings! As a beginner, I must apologize for the lack of finesse in my code. Currently, I am facing an issue with the positioning of my name (Tristen Roth) and the navbar-toggler-icon on xs viewports. They are appearing on separate lines vertically, lea ...

Expand the dimensions of the file upload field to make it taller and wider

I am trying to create a file upload field within a transparent div sized at 150px x 150px. The goal is for the file dialog box to pop up when any part of the div is clicked, allowing the user to select a file for upload. Despite my attempts, I haven't ...

Troubleshooting a vertical overflow problem with Flexbox

Struggling to design a portfolio page for FreeCodeCamp using flexbox layout due to vertical overflow issues. Here is the HTML: <div class="flex-container flex-column top"> <header class="flex-container"> <h1 class="logo"><i clas ...

Troubleshooting a malfunction in Bootstrap dropdown due to conflicting inner CSS styles

I created a header with bootstrap, but I noticed a glitch in the dropdown menu when I added an internal stylesheet for other elements on the same page. Even adding the Bootstrap CDN or jQuery CDN links did not resolve the issue. The header functions proper ...

Changing Parameters in Absolutely Positioned Sections

I have successfully created a fixed header with a higher z-index than the body content, allowing the content to slide underneath it. To position the content div directly below the fixed header, I applied a position:relative and specified a top value. Init ...

What is preventing window.scrollTo() from being executed?

I have implemented Bootstrap's Buttons plugin to toggle the state of a custom checkbox. When the button is toggled on, a hidden element should appear at the top of the page and then the page should scroll to the top. Similarly, when the button is togg ...

Concealing Form Values with Radio Buttons using HTML, CSS, and PHP

I'm working on creating a sign-in form with multiple options. I want users to be able to choose between signing in with their username or email using radio buttons. I'm wondering if there's a way to achieve this using HTML, CSS, and PHP, or ...

Display elements with a particular class using jQuery

I want to utilize jQuery to show all elements within a UL that have the class .active. Is this how my code should look? if ($(this).hasClass('active')) { $( ".active" ).show(); } This is my HTML structure <ul> <li>&l ...

Tips for eliminating gaps between navigation items (HTML / CSS)

I'm struggling to eliminate the spacing between the li items in my navigation bar. Even after setting margin: 0px for both the item and anchor (link), the gap still persists. How can I get rid of these spaces? /* navigation styles */ nav { backgroun ...

Center align a row with the help of Bootstrap 4.0

Here is some code with Bootstrap 4 classes that I am working with: <div class="container"> <div class="row"> <div class="col-xl-4 col-md-6 col-lg-4"> <div class="footer_widget"> <h3 class ...

Is it possible to utilize a contenteditable div in place of a textarea?

Is it possible to replace a textarea with a content editable div? Will the behavior be the same? Can data processing be done in the same way as with textarea data? ...

Is there a way to change the vertical spacing between two lines of text within a div element without relying on the position property?

I have a title and date section with two lines of text for my small blog. I need to reduce the vertical space between them so that they are closer together. Currently, there is a large gap. What is the best way to fix this? I've tried adjusting the po ...

Ways to ensure that an inner div causes the outer div to shift downward

Imagine I have a div. Within this div, there are two divs positioned side by side with the float left property. The div on the left is designated for an image. However, if the image is too tall, it does not expand the outer div to accommodate it. Instead ...

Diversify Your Color Palette with Sass Color Functions - Utilize Multiple Functions

Looking to make adjustments to a HSL color in one go, including hue, saturation, and lightness. I've tried applying each adjustment individually like this: $color: hsl color code; $new-color: adjust-hue($color, -1); $new-color: lighten($color, 20%); ...

What is the best way to synchronize the scale of images with the tempo of a song?

I just started learning CSS, JS, and HTML and I have a question about scaling an image based on a song. Despite searching through YouTube and various forums, I still haven't found a solution. Any help would be greatly appreciated :) Here is the HTML ...

How can you add padding to an HTML page using CSS?

I've been attempting to use padding-bottom:90px; in order to shift Tweets by ‎@StackOverflow (the entire tweets section) downwards on the page. I want to move it further down using the above padding, but it doesn't seem to be working for me. H ...

Modify the style of the list heading in CSS

I have a collection of items that are aligned to the left within their surrounding <div>. #list-container:before { content: 'The items:'; } #list-container span { display: block; } <div id="list-container"> <span>item1& ...