What is the best way to customize media queries in a child theme?

Is it possible to override a media query in my Wordpress child theme? Currently, the media query is set at max-width: 1024px, but I would like it to be triggered at a smaller size, maybe around 700px. The issue arises when attempting to create a new media query at 700px - while it is activated, it does not actually override the existing max-width: 1024px. How can I make sure that the parent theme's 1024px media query is ignored and the new 700px one takes precedence?

I am hesitant to edit the parent theme directly as any changes may be lost during updates. I have explored other resources without finding a solution:

Overriding media queries of parent css in Wordpress child-theme

This link did not provide an answer to my specific question.

Answer №1

  1. Transfer the specified guidelines under @media (max-width: 1024px) to the secondary stylesheet document.
  2. Modify the media query to
    @media (min-width: 700px) and (max-width: 1024px)
  3. Incorporate the personalized directives under @media (max-width: 700px) in the child style.css subsequent to adjusting the styles.

/* Stylesheet updated */

@media (min-width: 700px) and (max-width: 1024px) {
  .color {
    color: lightblue;
    transform: translateY(50px);
  }
}
/* Additional Child.css Rules */

@media (max-width: 700px) {
  .color {
    color: red;
  }
}
<div class="color">I can change my color and position only after 700px and before 1024px</div>

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

"Enhanced visuals with parallax scrolling feature implemented on various sections for an engaging

With 4 sections, each featuring a background image and text in the middle, I encountered an issue when attempting to have them fixed while scrolling. The goal was for the section below the first one to overlap the one above it along with its text as we scr ...

Revamp your Redux Form with a fresh new 'Field' label style

Is there a way to style the label of a Redux Form field? The Redux Form API does not provide information on how to apply styles to the label. Despite applying the classes.formField class, the label itself remains unstyled. Could this be an issue with inhe ...

Adjusting various settings on breakpoints in MUI v5

Previously in MUI version 4, I was able to apply multiple style parameters within a single media query using the following code: [theme.breakpoints.up('xs')]: { width: 100px, color: green, }, [theme.breakpoints.up('md' ...

Central AJAX spinner

I am having trouble centering the ajax loader. Currently, it is appearing in the right corner of the screen instead. Any help is appreciated. Below you can find the code snippet: div.amshopby-overlay { background-color: #fafafa; height: 100%; ...

Ways to Resolve Issues with WordPress Update and Publish Failures

It has been quite some time since Gutenberg was introduced to us, and it seems like we all have a complicated relationship with it. Navigating the Block editor to create a post or page can be challenging, especially when it used to be so simple. But what& ...

Incapable of utilizing CSS Custom Properties (also known as CSS Variables) in conjunction with SASS @if Conditional Statements

I'm attempting to transfer CSS Custom Properties to a SASS Mixin. I can successfully use the variables directly in the desired styling. However, there seems to be a problem when utilizing a variable within an If statement. Here's an example of t ...

Creating interactive buttons with CSS and jQuery

As a newcomer to coding, I'm trying my hand at creating two buttons that transition from green to blue with a single click, and eventually incorporating them into a live website. The functionality I'm aiming for includes: Both buttons startin ...

Displaying incorrect symbols with icon fonts

I have successfully integrated icon fonts into my simple web page. Check it out on jsFiddle here My design is similar to this example, but instead of bars, I see a snake icon displayed. How can I fix this issue with the fonts? Here is the code snippet: ...

Is less.js capable of compiling CSS code that is compatible with all browsers?

Is there a simple way to convert my Less code into browser-compatible CSS like the example below? #grad1 { background: -webkit-linear-gradient(red, blue); /* For Safari 5.1 to 6.0 */ background: -o-linear-gradient(red, blue); /* For Opera 11.1 to ...

Purchase Masonry Supplies for Optimal Arrangement

I've been using a neat little tool called jquery-isotope to create a masonry style layout for the blog posts on my website. It's set up with two columns, showcasing two different post types - long form articles and image-only posts. The masonry ...

Show schedule in an HTML chart

I'm currently working with a table that displays the current status of a request. An example of how the table looks in HTML is shown below: The table itself is quite simple, but I am having trouble figuring out how to effectively display the timeline ...

showcasing a set of div elements by using forward and backward buttons

I am dealing with 5 divs that have text content inside. To navigate through each div, I have implemented a back and next button system. <a href="" class="back-btn off">Back</a> | <a href="" class="next-btn">Next</a> <div class ...

Using CSS box-shadow to elevate an image

I am looking to create a background wrapper using CSS instead of an image. My goal is to add box shadow to achieve the same look as shown in the attached image. I understand that I will need to use the box-shadow property for this task. However, I am uns ...

Preserving the position of inline text

I've been working on a button design that I want to make look more realistic by moving the text down 1px inside the button when it's pressed. To achieve this effect, I added an extra pixel to the top and removed one from the bottom. However, the ...

Trouble pausing CSS slide using -webkit-animation-play-state:paused; finding it ineffective

Below is the code snippet in question: .picTransition .item { position: absolute; left: 0; right: 0; opacity: 0; -webkit-animation: picTransition 56s linear infinite; -moz-animation: picTransition 56s linear infinite; -ms-animation: ...

Buttons containing two lines of text appear bigger compared to those with only one line of text, but it is essential for all buttons to be consistent in size with the single line buttons

I am facing an issue with the buttons on my website, as they seem to resize based on the amount of text present. When there are 2 lines of text, the buttons appear larger compared to those with just one line. How can I rectify this situation? Although thi ...

best practices for creating space between flexbox items

My task involves presenting a continuous scroll list of scheduled jobs using Angular Material. Each item in the list needs to be divided into three columns utilizing flexbox. Despite my efforts, I am struggling with adding space between the columns within ...

The image's max-width property is not functioning as expected within a flexbox layout in Internet Explorer 11, yet it displays

I'm currently working on a 2 by 2 grid layout using flexbox, where the items in the first column are combined together. Check out the setup below: https://i.sstatic.net/fAhtu.png Everything looks great in Google Chrome but unfortunately, I've r ...

iOS users are experiencing issues with mobile responsiveness

I've encountered a strange issue with the mobile responsive design of a website. The website in question is While everything displays correctly on desktop using dev tools > responsive, and on any Android device, the problem arises when viewing i ...

(Material UI version 5) Custom global style enhancements

One of the examples in MUI is the Global style overrides: const theme = createTheme({ components: { // Name of the component MuiButton: { styleOverrides: { // Name of the slot root: { // Some CSS fontSize ...