The true meaning of CSS3 transition is often misconstr

I'm trying to create a simple linear transition effect, but for some reason it's not working. Any suggestions on what might be causing the issue?

HTML

<div class="button-modern" style="background-color:#e73032">
    <span style="color:#fff; font-size:1rem">MORE</span>
    <br><span style="color:#fff; font-size:2rem">INFORMATION</span>

    <div class="button-modern--info">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</div>
    <div class="button-modern--click js-button-modern--click"> 
       <span></span>
    </div>
</div>

CSS

.button-modern {
    padding: 18px 22px;
    position: relative;
}
.button-modern--opened .button-modern--info {
    text-transform: none;
    height: 100%;
}
.button-modern--click {
    width: 56px;
    height: 56px;
    position: absolute;
    bottom: 0;
    right: 0;
    overflow: hidden;
}
.button-modern--click > span:before {
    font-family:'FontAwesome';
    font-weight: normal;
    font-style: normal;
    speak: none;
    vertical-align: middle;
    font-size: 26px;
    content:" \F107";
    padding: 0 10px 0 0;
    color: #fff;
    position: absolute;
    right: 0;
    bottom: 0;
}
.button-modern--opened .button-modern--click > span:before {
    font-family:'FontAwesome';
    font-weight: normal;
    font-style: normal;
    speak: none;
    vertical-align: middle;
    font-size: 26px;
    content:" \F106";
    padding: 0 10px 0 0;
    color: #fff;
    position: absolute;
    right: 0;
    bottom: 0;
}
.button-modern--click > span {
    cursor: pointer;
}
.button-modern--info {
    height: 0;
    overflow: hidden;
    -webkit-transition: all 200ms linear;
    -moz-transition: all 200ms linear;
    transition: all 200ms linear;
}

JS

$('.button-modern').find('.js-button-modern--click').click(function (e) {
    $(this).parent().toggleClass('button-modern--opened');
});

JSFiddle http://jsfiddle.net/zilli/7rpEW/

Answer №1

The issue with the transition not functioning was due to it not being triggered when a class is added or removed, as there was no specific element to transition to/from.

$( ".btn-info" ).hide();
$( ".btn-click" ).click(function() {
    $(this).prev( ".btn-info" ).slideToggle( "slow" );
});

View jsFiddle example

In this case, I utilized .hide() to initially hide the element and then used .slideToggle to toggle its display.

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

Selector for the Nth child element

Struggling with the nth child selector. Here is the HTML snippet: HTML <div class="container"> <ul class="mh-menu"> <li> <a href="#"> <span>Chairman of the Board</span> <spa ...

Changing the color of a placeholder using Javascript: A step-by-step guide

I've been searching online without any luck so far. I'm attempting to change the placeholder color of a text box using JavaScript, but I'm not sure how to go about it. I already have a color picker that changes colors. If my CSS looks somet ...

Smooth scrolling for the entire webpage using jQuery

Does anyone know how to create a seamless mouse scrolling effect, similar to what is seen on this website? Check it out here: I have looked online, but haven't been able to find a satisfactory solution for this problem. ...

Utilizing JQuery to Access the Return Value from an Ajax Request Beyond the Scope of the Call

Hey there! I am currently facing an issue with an ajax call. The return value (data) from the call is stored in a variable called mydata, but unfortunately, I need to access this variable outside of the ajax call. Due to certain constraints, I cannot inc ...

Is there a potential bug when using .fadeOut() within a hidden element?

After examining the code provided: <div class='hotel_photo_select'> Hello </div> <div class='itsHidden' style='display:none'> <div class='hotel_photo_select'> Hello </ ...

Troubleshooting Variable Issues in PHP and JavaScript

On my PHP page, I have a while loop where I am retrieving the following... print $divLeft.strip_tags($row->twitterUser)."?size=normal\"/><br \/>".$row->twitterUser.$divRight."<a href='javascript:void(0);' id=&apos ...

Switching DropdownListFor Content in MVC4 with Bootstrap Design Activated

I am currently working on a partial view in MVC that contains two Razor dropdownlistfor elements. The first one is for selecting a customer, and the second one is for selecting a branch. @Html.DropDownListFor(model => model.CustomerId, new SelectList(M ...

Fast JSON retrieval

I am attempting to implement an instant search feature using json. Despite my efforts, the code does not seem to be functioning properly. Can someone kindly review it and assist me in resolving the issue? Thank you in advance. http://jsfiddle.net/hMyr7/ ...

Make a big picture fit into a tiny container

I have a question about image rendering. What occurs when we try to fit a large image into a small container? Consider, for example, creating an HTML page with a 100x100 px image on a device with a pixel ratio of 2. Situation 1: Placing the image inside a ...

What is the best way to divide my value sets using jQuery?

Within a given string such as 28_34/42/34,23_21/67/12,63_5/6/56, I am seeking to split or eliminate sets based on the ID provided. For example, if the ID is 23, then the set 23_21/67/12 should be removed. To achieve this, I am checking the value after the ...

Alter the dimensions and material displayed on Vue

In my Vue.js project, I have a topbar with two divs whose size and content need to be adjusted based on whether the user is logged in. If they are not logged in, it should look like this: <div id='search' width="400px"></div><div ...

Exploring a JSON object and dynamically populating FormData with values using jquery

I am working with a JSON object in jQuery that looks like this: userObj = { "loginId":"abc123", "class":"5", "email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3f5e5457565311584b4c0e0606087f58525e5653115c5052">[e ...

Turn off the default automatic AJAX request for DataTables server-side paging

Currently, my dataTable is set up with server-side paging and it works correctly. The table fetches data via ajax during initialization. However, I now require the table to be empty initially and load data only when a button is clicked using either the loa ...

I'm curious about the location where label_color keys are stored within apache-superset

Version: I have installed a Docker instance of Superset from this source The documentation mentions that colors can be customized based on labels, as explained here. To achieve this, it is necessary to provide a mapping of labels to colors in the JSON ...

Changing characters to asterisks using Javascript

I am currently working on a function that transforms all characters after the first word into asterisks. For example, if I have MYFIRSTWORD MYSECONDWORD, I would like it to show as: MYFIRSTWORD *** Currently, I'm using the code below which replaces ...

How can I achieve auto-refresh functionality in SQLite using PHP and JavaScript without refreshing the entire page

I am currently working with a straightforward php code that retrieves data from a SQLite database by using the query "$query ="Select A from B"". The process works smoothly, and upon updating the SQLite database, I can refresh the page to display the new d ...

Add information to the Database seamlessly without the need to refresh the page using PHP in combination with JQuery

Check out my code below: <form action='insert.php' method='post' id='myform'> <input type='hidden' name='tmdb_id'/> <button id='insert'>Insert</button> <p i ...

combining all JavaScript script tags into a single tag

I'm currently working with wavesurfer.js and have the following setup: 'use strict' <!-- wavesurfer.js --> <script src="src/wavesurfer.js"></script> <script src="src/util.js"></script> <scrip ...

The seamless integration of AngularJS and the chosen library is proving to be

When I use a chosen select to load data from a JSON file in an AngularJS application, the data loads successfully with a standard HTML select. However, if I switch to using the chosen select, the data does not load. I understand that the data is fetched af ...

Retrieve the value of the chosen option from a dropdown menu that adjusts dynamically within

I have a query that involves dynamically adding rows to a table for data insertion. A particular <td> element houses a dropdown menu, and I need to extract the selected value from this dropdown in order to make an AJAX call back to a PHP script that ...