What are the steps for implementing responsive design animation in my particular scenario?

Can someone please help me with a strange bug in Chrome?

I am trying to create a responsive design for my app.

The width of the 'item' element should change based on the browser's width. It works fine when the page first loads in Chrome, but after I click on the 'item' and run the animation, the width does not adjust as the browser is resized. This seems to be an issue with the animation in Chrome specifically. Any suggestions would be greatly appreciated. Thanks!

http://jsfiddle.net/7kvX2/3/

html

 <div id="wrapper">
     <div class='item'>test 1</div>
     <div class='item'>test 2</div>
     <div class='item'>test 3</div>
 </div>

css

.item{
    display:inline-block;
    background-color:yellow;
}

.open{
    -webkit-animation: openMenu 1s;
    animation:openMenu 1s;
}

.close{
    -webkit-animation: closeMenu 1s;
    animation:closeMenu 1s;
}

@media (min-width: 800px) and (max-width: 1000px) {
    .item{
        width:105px;
    }

    @-webkit-keyframes openMenu{
        from {width: 105px;}
        to   {width: 170px;}
    }

    @keyframes openMenu{
        from {width: 105px;}
        to   {width: 170px;}
    }

    @-webkit-keyframes closeMenu{
        from {width: 170px;}
        to   {width: 105px;}
    }
    @keyframes closeMenu{
        from {width: 170px;}
        to   {width: 105px;}
    }
}


@media (min-width: 400px) and (max-width: 800px) {
    .item{
        width:75px;
    }

    @-webkit-keyframes openMenu{
        from {width: 75px;}
        to   {width: 100px;}
    }

    @keyframes openMenu{
        from {width: 75px;}
        to   {width: 100px;}
    }

    @-webkit-keyframes closeMenu{
        from {width: 100px;}
        to   {width: 75px;}
    }
    @keyframes closeMenu{
        from {width: 100px;}
        to   {width: 75px;}
    }
}

js

$('.item').click(function(){
    if($(this).hasClass('open')){
        $(this).addClass('close').removeClass('open');

    }else{
        $(this).addClass('open').removeClass('close');
    }
})

Answer №1

Check out this fiddle for a solution to your problem: http://jsfiddle.net/7kvX2/4/

I noticed that your breakpoints were slightly off and only worked if you fell exactly in between them.

To fix this, I made some adjustments by removing the upper constraint on the first media query:

@media (min-width: 800px){

Then, I set the lower constraint smaller and adjusted the second parameter to 799 on the second media query:

@media (min-width: 100px) and (max-width: 799px) {

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

Google has not detected any hreflang return tag

My website has encountered indexing errors on Google Search Console. According to the reports, many pages are showing an alternate version in a different language without the "return tag". This "return tag" is believed to be the pointer back to the origina ...

tips for applying a where clause on a jsonb column in an included table with sequelize

I currently have 2 tables stored in a postgres database. Table_A -------- id BIGINT metadata JSONB Table_B -------- id BIGINT a_id BIGINT metadata JSONB Data Table_A id | metadata 1 | {'gender': 'Male', 'name': 'xyz&ap ...

Creating a variable that is named after an existing variable

Creating a new variable with a dynamic name can be tricky. Let's take a look at an example: function preloader(imglist) { var imgs = imglist.split("|"); for (i in imgs) { var img_{i} = new Image; img_{i}.src = imgs[i]; ...

The presence of the StickyHeader Row is causing an obstruction in the drop down list view

I have successfully made the row header of the Material UI Table component sticky by utilizing the stickyHeader attribute. <Table stickyHeader className={classes.table}></Table> Above this table, there are two drop-downs that are created using ...

Discovering the method for accessing nested JSON data through ng-repeat in AngularJS

I'm attempting to access the items._id value within ng-view using ng-repeat. I am able to retrieve all data, but I am interested in specific data only. Data.json [ { _id : "td6v9db4514cc4ewew4334", firstName : 'ayaz', la ...

Content does not become interactive upon the initial loading of the page

I've modified a W3 schools slideshow template to use text instead of dots, but I'm encountering two issues 1: The first image doesn't load when the page loads. Although using a class ID and setting it to active fixes this issue, it leads to ...

Insert a CSS Class into an HTML div element with JQuery

I'm faced with a bit of a challenge. Here's the scenario: <div class="portItem"></div> <div class="portItem"></div> <div class="portItem"></div> <div class="p ...

What could be causing the inaccuracies in the way my Array data is being transferred to my MySQL

Recently, I had the opportunity to learn how to convert a JSON file into an array with the help of a generous stackoverflow user. The process was successful, but when I attempted to input this data into my database, I encountered unexpected results. Array ...

What is the latest CSS browser support for the min() and max() functions in 2018?

I am considering implementing the use of the min() and max() functions in my project. I'm curious about the current browser support as of 2018. Do you think it is necessary to include the @supports at-rule? For example, I could write: .px-4-safe { ...

Unable to activate check box button by clicking on it

Hi there! I am having trouble with a checkbox button on my website. The button appears fine, but for some reason it's not working properly (it doesn't get unchecked when clicked). Can anyone help me fix this issue? I'm still learning HTML an ...

What steps can be taken to avoid being logged out automatically upon clicking the back button?

Currently, my code automatically logs out of the application when the browser is closed. However, I am facing an issue where it also logs out when I press the browser's back button and navigate to another page. I would like the code to only logout au ...

The Javascript function is designed to function exclusively with onclick events or setTimeout functions

I am currently working on a website that I want to be responsive to the window size. However, I am facing an issue with vertical alignment. I have created a jQuery function to handle this, and it works well for divs with images but not so well for a div wi ...

Interactive feature on Google Maps information window allowing navigation to page's functions

Working on an Angular2 / Ionic 2 mobile App, I am utilizing the google maps JS API to display markers on a map. Upon clicking a marker, an information window pops up containing text and a button that triggers a function when clicked. If this function simpl ...

When a custom header is added, cookies are not included in cross-origin jQuery AJAX requests

An issue arises when sending an ajax request from our main domain to a subdomain (cross-origin) through jQuery. Despite having CORS implemented and functional, we encounter a problem when attempting to include a custom header in the request. The presence o ...

PHP fails to retrieve data from a JavaScript Ajax function using the FormData object (specifically, when

I'm facing an issue where my file is not being detected when I send a FormData object using AJAX and PHP code. Both the `$_FILES` array and the `$_POST` array appear to be empty. However, the browser does send the file with the AJAX request. <inpu ...

Button group malfunctions on smaller screens

After integrating a button group into my new website, I noticed that the first two buttons stop functioning properly on smaller screens. Surprisingly, if I remove the text-center div, all buttons cease to work entirely. Despite attempting various solution ...

Interactive search tool with multiple fields using HTML and JavaScript

I need help developing a search box for structured data, where I want to implement two types of typeahead searches: one for fields and another for values within those fields. The image below illustrates what I am aiming for. My backend systems are all set ...

What is the process for creating a hover linear wipe transition using CSS/JS?

It's worth noting that I can't simply stack one image on top of the other because I'll be dealing with transparent images as well. preview of linear wipe ...

Is It Acceptable for CSS Code to Contradict Default CSS Code?

Imagine if my CSS looks like this: div { margin: 0; overflow: auto; padding: 1%; text-align: center; word-wrap: break-word; } This is supposed to be the default styling for all div elements. But what happens if there's another div with conflicting c ...

Using AngularJS location.path for unique custom URLs

Control Code: $scope.$on('$locationChangeStart', function () { var path = $location.path(); var adminPath = '/admin/' ; if(path.match(adminPath)) { $scope.adminContainer= function() { return true; }; }); HTML <div clas ...