CSS padding not functioning properly within media queries

I have the following CSS code:

ui-tabs .ui-tabs-nav .ui-tabs-anchor {
    float: left;
    padding: .5em 1em;
    text-decoration: none;
}

And this is the CSS code for media queries:

@media only screen and (max-width : 500px) {
.ui-tabs .ui-tabs-nav .ui-tabs-anchor
{
    float: left;
    background-color:red;
    padding: 0;
    text-decoration: none;
}
}

The padding in the media query doesn't seem to work as expected. The div still retains the previous padding value, although the background color changes to red. Why does the padding remain at the old value?

Edit

This is how it appears in normal size:

This is how it looks when the window size changes:

This is the appearance after removing the padding using the browser tools:

HTML

<img src="Styles/purpleLogo.gif" style="float:left;"/>
    <div id="newUpContainer" style="width: 100%; float: left;">
        <div id="onlineBookingDiv" style="float: right; width: 49%;  padding-bottom: 10px;">
            <div id="tabs">
                <ul>
                    <li><a href="#tabs-1">Today</a></li>
                    <li><a href="#tabs-2">Tomorrow</a></li>
                    <li><a href="#tabs-3">Any Date</a></li>
                    <li style="float: right; position: relative; right:2px">
                    <label >
                        <asp:DropDownList AutoPostBack="true" runat="server" ID="mealTimeSelector" OnSelectedIndexChanged="TodayTab_Click">
                            <asp:ListItem Value="1">Breakfast</asp:ListItem>
                            <asp:ListItem Value="2">Lunch</asp:ListItem>
                            <asp:ListItem Value="3">Dinner</asp:ListItem>
                        </asp:DropDownList>
                    </label>
                        </li>
                </ul>

Edit2

HTML from Firefox page source:

<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" role="tablist">
                    <li class="ui-state-default ui-corner-top ui-tabs-active ui-state-active" role="tab" tabindex="0" aria-controls="tabs-1" aria-labelledby="ui-id-1" aria-selected="true"><a href="#tabs-1" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-1">Today</a></li>
                    <li class="ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="tabs-2" aria-labelledby="ui-id-2" aria-selected="false"><a href="#tabs-2" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-2">Tomorrow</a></li>
                    <li class="ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="tabs-3" aria-labelledby="ui-id-3" aria-selected="false"><a href="#tabs-3" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-3">Any Date</a></li>
                    <li style="float: right; position: relative; right:2px">
                    <label>
                        <select name="ctl00$MainContent$mealTimeSelector" onchange="javascript:setTimeout('__doPostBack(\'ctl00$MainContent$mealTimeSelector\',\'\')', 0)" id="MainContent_mealTimeSelector">
    <option selected="selected" value="1">Breakfast</option>
    <option value="2">Lunch</option>
    <option value="3">Dinner</option>

</select>
                    </label>
                        </li>
                </ul>

Answer №1

Here is a suggestion to consider:

@media only screen and (max-width: 500px) {
.ui-tabs .ui-tabs-nav .ui-tabs-anchor
    {
        float: left;
        background-color: red;
        padding: 0 !important;
        text-decoration: none;
    }
}

Based on my observation, it seems that the padding may not be set correctly in other parts of the code. By applying this method, you can ensure that the padding is being overwritten.

Alternatively, you can experiment by setting a positive padding value in the media query and removing the default padding to test its impact. This will help confirm whether the media query functions as expected.

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

ASP.NET MVC - The key 'País' does not have a ViewData item of type 'IEnumerable<SelectListItem>'

Encountering an issue while sending data from View to Controller, View section: @model Projeto_P1.Models.Cidade @{ ViewBag.Title = "City Registration"; } @using (Html.BeginForm("AddCity", "General", FormMethod.Post)) { <div class="container"& ...

DataTables.js, the powerful JavaScript library for creating interactive tables, and its compatible counterpart

I'm currently making some changes to a dynamic table that require enabling a vertical scroll bar. As a result, I need to implement this vertical scroll bar mechanism on an existing table. The code in our project utilizes dataTables.js version 1.5.2 ...

Having trouble getting padding to work inside a pre block, even when using a wrapper div?

Snippet of HTML Code: <div class="prewrap"> <pre> stepsize = .01 samplestimes = 30 universex = seq(-1, 1, stepsize) universey = sin(pi * universex) </pre> </div> Sample CSS Styles: #prewrap { background-color: #e3e3e3; pa ...

applying a css class to a particular element within a custom user interface module

My left side navigation is a user control with multiple links to different aspx pages, such as <a href="a.aspx" id="aPage">A</a> <a href="b.aspx" id="bPage">B</a> <a href="c.aspx" id="cPage">C</a> When on a specific pa ...

Issue with firing events from a button located within a templated control

I am encountering an issue with triggering events from within my templated control. Although my actual control is more complex and includes additional templates, the core structure is similar to this: <MyControl> <SomeTemplate> &l ...

CSS tooltip within the document styling

Previously, I utilized the following code: I am seeking guidance on how to position the tooltip inline (to the right) with the parent div instead of above. Thank you for reviewing For a more user-friendly version, refer to this jsFiddle link HTML: < ...

The value of a DataRow column can vary depending on how it is read, showing a different result each time

Having some trouble extracting values from a DataSet in C#/ASP.NET that is returned from a stored procedure. Usually, when I pass the DefaultView from the DataSet into a GridView on an ASP.NET page, a specific column that interests me has a value. However, ...

What is the best method to style a child input element's placeholder using Tailwind CSS?

I'm currently working on a project and trying to translate a CSS style that targets the ::placeholder pseudo-element into Tailwind CSS. However, I have encountered some challenges during this process as I'm not entirely sure of the correct approa ...

Difficulty with displaying an image dynamically generated in Django

Display: import numpy as np import matplotlib.pyplot as plt import os def show_graph(request): # CREATE GRAPH filename = "graph.png" directory = "home/templates/home" full_directory_path = os.path.join(directory, filename) # Divided into 7 different c ...

Arrange fixed-position elements so that they adhere to the boundaries of their adjacent siblings

Is there a way to keep two fixed elements aligned with their sibling element on window resize? <div class="left-img"> IMAGE HERE </div> <!-- fixed positioned --> <div class="container"> Lorem ipsum... </div> <div class=" ...

I have been attempting to extract real estate listings from an MLS website using Beautiful Soup and have found some success. I am now considering if using Selenium would be a more efficient option

Perhaps this question has been answered before, which could help guide me in the right direction. The website loads 24 listings at a time and then displays a "see more results" button to load the next batch of 24 listings while keeping the initial 24 visib ...

Is there a way to show the input value in a different form while still retaining the original value?

When receiving a pagination number from user input, I store it in a variable like so: $html .= "<input type='submit' name='next' value='$next_page_number' />"; Now, I'm looking to replace the displayed text for th ...

Tips for designing a responsive element with a repeating border

Desired Design: Create a dotted border on top of each li-element Adjust the size of the dots and spacing between them using CSS or image/SVG manipulation Make the width of the ul responsive for varying border widths Ensure that dots are not partially dis ...

Guide on implementing mouse Click event for 3-dimensional model

I recently added a 3D collada (.dae) file to my scene. This 'DAE' file includes geometry named "monster" with the id "monster-mesh-skin". I attempted to apply a mouse click event to the "monster" geometry using the following code: var monster = ...

Strange HTML antics

On my website, I encountered an issue when trying to register without entering any information into the required fields. The errors were correctly displayed in this screenshot: https://i.sstatic.net/wrxjt.png However, after inserting random characters in ...

A fresh javascript HTML element does not adhere to the css guidelines

While attempting to dynamically add rows to a table using Javascript and jQuery, I encountered an issue. Here is my code: <script> $(document).ready(function(){ for (i=0; i<myvar.length; i++){ $("#items").after('<tr class="item- ...

Is there a way to keep my footer fixed to the bottom of the page in Google Chrome?

I recently made some updates to my aging website by adding a footer menu. However, I encountered an issue with the placement of the footer on Google Chrome. It appears too high, overlapping certain elements of the site. I attempted to resolve this problem ...

Display a Bootstrap modal based on the user's selection after clicking on a radio button

I am currently working on a Flask web application and I am looking to implement bootstrap modals based on the user's selection of a radio button. After the user selects a radio button and clicks 'OK', I want a specific modal to appear. Right ...

Guide on centering an unfamiliar element in the viewport using HTML, CSS, and JavaScript

In the process of developing my VueJS project, I have successfully implemented a series of cards on the page. However, I am now facing a challenge - when a user selects one of these cards, I want it to move to the center of the screen while maintaining its ...

Adjusting the vertical alignment of wrapped divs with jQuery toggle

I am currently working on a project where I have a set of dynamically generated divs, each containing rows of content with three columns. Using jQuery toggle, I am trying to show and hide certain elements within the divs without affecting their layout. Her ...