I'm having trouble making my jQuery banner responsive - which property should I be using in this situation?

I am experiencing an issue with my jQuery banner not shrinking properly. In my mobile.css file, I have set the class .banner width to 100%, but it is not shrinking to a width of 260px as expected. I would like to know which property I need to use in order to achieve this. You can check out the hosted version on the web server by clicking on this link:


<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="slider/css/skitter.styles.css" type="text/css" media="all" rel="stylesheet" />
<script src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" language="javascript" src="slider/js/jquery.easing.1.3.js"></script>
<script type="text/javascript" language="javascript" src="slider/js/jquery.skitter.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$('.box_skitter_large').skitter({
theme: 'clean',
numbers_align: 'center',
progressbar: true,
dots: true,
preview: true
});
});
</script>
</head>
<body>
   <div class="banner">
        <div class="border_box">
            <div class="box_skitter box_skitter_large">
                <ul>
                    <li><a href="#cubeRandom"><img src="slider/images/example/1.jpg" class="circles" /></a><div class="label_text"><p>One</p></div></li>
                    <li><a href="#block"><img src="slider/images/example/2.jpg" class="circles" /></a><div class="label_text"><p>Two</p></div></li>
                    <li><a href="#cubeRandom"><img src="slider/images/example/3.jpg" class="circles" /></a><div class="label_text"><p>Three</p></div></li>
                    ...
                </ul>
            </div>
        </div>
    </div>
    <!--End of banner-->
</body>
</html>

My default css:

body {
/*background-color:#F2F2F2;*/
background-color: #FFF;
padding: 0px;
margin: 0px;
font-weight: normal;
font-family: Arial;
}
...
.my mobile.css:

@media only screen and (max-width:530px)
{
#wrapper
{
width:260px;
}
.header
{
width:260px;
height:auto;
}
.logo
{
width:260px;
height:90px;
text-align:center;
}

.banner
{
width:100%;
}
.banner img
{
width:100%;
height:100px;
}
}

Answer №1

To ensure that your media query styles take precedence over your default styles, they need to have higher specificity or appear later in your stylesheet. One simple solution is to rearrange your style rules. Alternatively, you can include a second media query like this:

@media only screen and (min-width:531px)
{
    .banner {
        width: 1000px;
    }
}

By removing the width property from the regular .banner style and relying on the media queries for all width rules, you can streamline your CSS.

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

How to trigger a mouse click event in a ReactJS environment

I am working on a project where I need to simulate a click (on the first item in a collapsed list) automatically without requiring any user interaction. The list collapsing feature is implemented using Material UI. Any suggestions or ideas would be great ...

What changes can I make to this jquery code to utilize a background image instead of a background color?

Can someone help me modify this snippet to set a background-image instead of changing the background color? <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("#button_layer").hide(); $("#im ...

Is there a way to slow down the falling effect on my navigation bar?

As I was working on my personal website, I had a creative idea to add a falling-down animated effect instead of keeping the layout fixed. Utilizing bootstrap for navigation, I encountered some difficulty in controlling the speed of the falling effect. Any ...

Only fire the click event of the parent div if none of the child elements are clicked

Here is a fiddle I've prepared for reference: https://jsfiddle.net/9m4bgyq8/16/ The issue I am facing is that I am attempting to wrap a checkbox and label within a div, and apply a click event to the div. The intention is for the click event to only ...

Differences between Animation Easing in iOS and CSS3 Cubic Bezier Functions

I am currently working on an iOS app and I am trying to improve the animations within it. Having a lot of experience with CSS3 animation and transitions, I want to be able to define my animations in iOS with the same precision that is possible with CSS3 ( ...

Align a single item to the right in PrimeNG p-menubar

I am currently utilizing PrimeNG 8.1.1 and I am looking for a way to align one of the items to the right side (specifically the submenu options of logout and profile). Does anyone have any suggestions? this._menuItems = [ { labe ...

Using PHP and jQuery to output content in HTML

I am facing an issue with displaying HTML content fetched from a database using the following code: $("#menuOverlay").append('<?php include('aggiungiPaginaComp.php');?>'); Although the code is functioning properly, when I view t ...

Tips for showcasing numerical values using radio buttons

Hello, I am currently working on my project and have a question about calling the ajax function when clicking a button. If(isset($_POST) && ($_POST['GET_PAYMENT'] == '1')) { $totalAmount = $_POST['GET_PAYMENT']; //Total amo ...

Creating an Array from jSoup Elements in Java: What's the Best Approach?

Is there a way to extract values from HTML attributes (values="valueIWant") and store them in an array? I have attempted the following method without success: HttpEntity entity5 = response5.getEntity(); String defaultString = EntityUtils.toString(enti ...

The curious case of unusual behavior in jQuery's livequery() method

When attempting to use the jQuery plugin "livequery" to highlight certain words within dynamically generated search results, the highlighting does not appear to work! Strangely, adding an alert() function before executing the code causes the highlighting ...

Basic progress bar

I'm attempting to create a basic download bar, but it's only displaying as a solid color without any transition animation. Furthermore, the "repeating-linear-gradient" feature isn't functioning and I'm struggling to figure out why. I&a ...

Overflow issues with CSS FlexBoxLayout

I am currently working on creating a website using Bootstrap and CSS's flexbox. My goal is to create a list that fits the height of the screen without overflowing it. After some trial and error, I managed to come up with a solution that looks like th ...

What is the best way to begin an ordered list from the number 2 instead of 1, while ensuring W3C validity and compatibility with

Is it possible to start an ordered list from 2 instead of 1? I need the solution to be compatible with all browsers, including IE6, and ensure that the HTML and CSS are valid. ...

How can one use an ajax call to delete rows from a table and then add new rows in their

Hey everyone, I'm looking to make an AJAX call and when it's successful, I want to remove all existing elements in my table and replace them with new ones based on the returned data. This is the method I have for making the AJAX call: $(document ...

What is the best way to verify all the UL elements within a hierarchy of checkboxes

Query: In my category listings, some categories have children. I am attempting to implement an "ALL" category that, when selected, will automatically check all sibling checkboxes in the same category. For example, clicking on ALL under the MUSIC category ...

Creating custom CSS for Styled Components in ReactJS

I'm struggling with CSS in React using styled components. Below is the code snippet I am working with: import React from 'react'; import { Navbar, Container, Row, Col } from 'reactstrap'; import styled from 'styled-components& ...

Footer rises with bootstrap zooming

Hey everyone! I'm a beginner in the world of web development and currently working on creating my own website. I've run into an issue with my footer - I want it to stay fixed at the bottom even when zoomed in, but for some reason, when I zoom in, ...

Saving and retrieving user input as a variable using Javascript and HTML local storage

This is the foundation of my HTML page. When the "remember text" paragraph is clicked, the data in the input text box is saved to local storage as a string. Clicking the "recall text" paragraph loads the stored data into the "recalled text" paragraph. I am ...

MTG Life counter. Display fluctuations in count

I am currently working on a fun project creating an MTG (Magic The Gathering) life tracker, even though the code is quite messy. Despite its flaws, it still gets the job done. Click here to view the MTG life tracker https://i.stack.imgur.com/Su17J.png ...

When double quotes are used in a string within an HTML input field, they may display as &

Using PHP, I am retrieving data from an SQL database and generating JavaScript code to create an edit button for each entry. The edit button triggers a text input field within a form. When the user clicks on the generated edit button, the text in this inpu ...