After implementing jQuery, media queries may not function as intended

My approach involves using media queries to adjust the width and height of specific div elements when the window is resized. Additionally, I utilize jQuery to increase their size on mouseover. However, I have encountered an issue where the execution of jQuery disrupts the functionality of the media queries. Consequently, after resizing, the div elements retain the dimensions set by jQuery, and the styles from the media queries are not applied. Apologies for any confusion in my explanation due to language barriers.

css

@media only screen and (max-width:1100px)
{
 .kruh
 {
    width: 150px;
    height: 150px;
 }
}
@media only screen and (max-width:850px)
{
 .kruh
 {
    width: 100px;
    height: 100px;
 }
}

and jQuery

var s = $("#kruh1").width();
var d=s+10;

$("#kruh1").mouseover(function()
 {
   $("#kruh1").animate({width: d+"", height: d+""}, );
 });

$("#kruh1").mouseout(function()
 {
   $("#kruh1").animate({width: s+"", height: s+""}, );
 });

Answer â„–1

Avoid using jQuery in this scenario as CSS is more suitable for the task.

.circle {
  transition: transform 0.4s ease;
}
@media only screen and (max-width:1100px) {
  .circle {
    width: 150px;
    height: 150px;
  }
  .circle:hover {
    transform: scale(1.07);
  }
}
@media only screen and (max-width:850px) {
  .circle {
    width: 100px;
    height: 100px;
  }
  .circle:hover {
    transform: scale(1.1);
  }
}

It's important to note that in your CSS, you are targeting an element with the class of .circle, while in your jQuery, you are targeting an element with the id of #kruh1.

Without displaying the HTML code as well, it is difficult for others to determine if their suggestions will work for you.

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

When I apply position: absolute; to my navigation bar, the anchor tags and links do not seem to function properly, especially with a video playing in the background

How can I make my anchor tags/links work properly on a header with a video in the "background" and a menu on top? HTML <nav class="menu"> <a href="#" target="_blank">ABOUT</a> <a href="#" target="_blank">PRICES</a&g ...

My CakePHP controller is not receiving the POST data as expected

I'm currently working on implementing AJAX in a knockout.js form to send data to CakePHP, but for some reason CakePHP is unable to receive the information. Additionally, despite receiving a 200 status (OK) from the POST request, the alert message is n ...

Ways to make an area map more transparent

I'm encountering an issue with HTML opacity... Currently, I've implemented opacity using CSS but it's not functioning correctly. Below is my HTML and CSS code: <area shape ="rect" class="transbox" coords ="0,0,30,22" href ="test1.htm" ...

Is there a way to remove the grey overlay when clicking on an <a> tag?

I want to develop a Hybrid app. On a webpage, I have buttons displayed in the following format: <a href="#"> <div style = "height: 50px; width: 50px; background-color: #00ff00; margin: 32px"></div> </a> Whenever I tap and hold ...

SQL table not being updated by AJAX request data submission

I'm encountering an issue when trying to update a SQL table with form data sent via a JQuery AJAX POST. Even after using mysql_error(), no errors are being returned. As a troubleshooting step, I appended "-Test Test" to my textarea input. This addi ...

Pass an array of objects through jQuery

I am working with an array of objects... [.main-header: Object, .main-header-free: Object, .sub-header-lunch-price: Object, .sub-header-week: Object, .sub-header-week-week: Object…] Within this array, one object looks like: .main-header: Object backgr ...

Tips for choosing classes with identical names without resorting to incremental IDs

https://i.stack.imgur.com/EVQVF.pngAre there alternative methods to select classes with the same name but in different table rows? Currently, I am using html class="className + id" and then in jquery to select $('.className'+id)... some code. Is ...

Dynamically load an external JavaScript file based on the presence or absence of specific elements on the webpage

Hi there, I have a question for you all. Situation: We are using a javascript tool to conduct A/B testing on our landing page designs. I want version A (control) to be linked to one external javascript file, while version B (variation) is linked to a diff ...

Is there a way to apply two distinct styles to a single component on a webpage?

Currently, I am in the process of developing a web application using Node JS, React, and Bootstrap. Within the application, I have implemented a main menu and a secondary menu using tabs. I have successfully defined a style for the main menu, but I am faci ...

Grabbing the HTML value and storing it in a JavaScript variable

In my table, each row has multiple columns including one with a checkbox. When this checkbox is checked, a new column cell appears to the right of the table with an up/down spinner to adjust a value. The issue I'm facing is that I want to limit the s ...

Integrate jQuery into your Django project

Having trouble integrating jQuery into my Django app. Not sure what went wrong as the button click is not producing any results. Here's a snippet of my code: base.html {% load static %} <html> <head> <link rel ...

Unable to receive AJAX response for the GET request

I am attempting to achieve the following: Upon clicking on H1, jQuery is supposed to retrieve information for a specific key from the server and display it in a prompt. The PHP code resides in server.php. $link = mysql_connect("mysql.hostinger.com.ua", "_ ...

Revise the absolute positioning of the child container (modal window)

I am facing an issue with a modal window that is fetched from the server and added to a container with absolute positioning. When I try to open the window, it does not display correctly as it gets positioned inside the container, causing most of it to be h ...

I'm having trouble defining the ajax url path. Does anyone know how to accurately retrieve the file path for wordpress in the ajax

Encountering an issue with the ajax URL path in Wordpress. It functions properly on my localhost, but fails to work on the server. The upload-file.php file is located at domainname.com/wp-content/themes/mytheme/upload-file.php. How can I specify the URL pa ...

The printed Bootstrap web page is being truncated

I have a unique dynamic webpage created with Bootstrap that needs to be printable. I am implementing media queries for styling the page when printing: /** Custom Print Styles **/ @media print { header, .menu, footer { display: none; ...

Error in React: Mixing units is not allowed when using vw and px together in the css calc() function

Is there a way to create fluid font size using the css calc() function in React without running into errors when mixing vw and px units? font-size: calc(14px + (26px - 14px)) * ((100vw - 300px) / (1600 - 300)); I encountered an error where SASS was unabl ...

Consistent sizing for Bootstrap thumbnail images

In my current project, I am implementing a Bootstrap thumbnail feature where each thumbnail consists of an image and a heading. However, a problem arose as the images do not have the same size, resulting in thumbnails with varying dimensions. To resolve th ...

CSS style for tables with inner gutters only

I am attempting to create a table layout with spacing between cells but without any external space for the cells at the border. I have written a simple code snippet to illustrate my issue: html, body, div, table, caption, tbody, tfoot, thead, tr, th, td ...

File extension being lost when dropped in AJAX request

I am currently working on a script that uses AJAX to delete an image. PHP foreach ( $in_folder as $img => $v ) { echo ' <span class="imageHolder"> <a onclick="DeleteImage('.$img.'); return false;" href="j ...

Using jQuery to update a label within a checkbox list

I'm facing a challenge in jQuery where I am attempting to dynamically replace labels with hyperlinks. Unfortunately, my current code doesn't seem to be working as expected. My goal is to assign a specific hyperlink to each list item based on its ...