Conflicting media queries

Attempting to resolve the issue of site content overlapping with the background slider plugin on a WordPress website, I have encountered conflicting media queries for different devices. While it may work perfectly on mobile devices, it can create problems on iPads or in landscape mode.

Here are the CSS media queries I am currently using:

/*------ MEDIA QUERIES------ */


/* iPhone 6/7 Portrait */

@media only screen and (min-device-width: 375px) and (max-device-width: 667px) and (orientation: portrait) and (-webkit-min-device-pixel-ratio: 2) {
  .HomePageBody {
    margin-top: -970px !important;
  }
  .nivoSlider {
    top: 40px;
    min-height: 500px !important;
    width: 100%;
    overflow: hidden;
  }
}


/* iPhone 6/7 Landscape */

@media only screen and (min-device-width: 375px) and (max-device-width: 667px) and (orientation: landscape) and (-webkit-min-device-pixel-ratio: 2) {
  .HomePageBody {
    margin-top: -110px !important;
  }
  .nivoSlider {
    top: 40px;
    min-height: 500px !important;
    width: 100%;
    overflow: hidden;
  }
  .site-content {
    margin-top: -320px !important;
  }
}

Answer №1

With the deprecation of min/max-device-width, a solution is using the orientation queries to target portrait and landscape styles. Here's an example implementation:

@media (orientation: landscape) {
...
}

@media (orientation: portrait) {
...
}

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

Guide on creating frozen columns in an Angular 2 table with the ability to scroll through multiple columns

Within my table, there are 3 columns that must always remain on the left side. Additionally, there is a column containing a grid where each element represents an hour of the day, requiring it to be scrollable. I have attempted various proposed solutions, ...

React js background image not filling the entire screen

Having experience with React Native, I decided to give ReactJS a try. However, I'm struggling with styling my components because CSS is not my strong suit. To build a small web application, I am using the Ant Design UI framework. Currently, I have a ...

What is the reason that the css backdrop-filter: blur() is functioning properly everywhere except on the active bootstrap-4 list-group-item?

I have a gallery with an album-card component inside, and within that is a carousel. I noticed that when I add a list-group and set one of the items as active, it remains unblurred. Can anyone help me understand why? Here is the HTML for the gallery com ...

Is there a way to prevent a tag from being clickable on the entire row, except for the actual link itself?

My question is why, when using the a tag, the entire row on the right becomes clickable as well? Despite there being no link, the area at the back of the row on the right side is clickable. Is there any way to remove this clickable area? <a id="ba ...

Is there a way to display a vertical list in a horizontal orientation?

I am in the process of creating my portfolio on Cargo Collective and have customized one of their pre-made themes to suit my preferences. The only thing I'm currently struggling with is how to change a set of vertical links to display horizontally ins ...

Is there a way to quickly toggle between CSS properties in the Styles tab of Chrome Devtools/Inspector using a keyboard shortcut?

While I typically rely on Firefox and Firebug for CSS testing and tweaking, I am now trying to transition to Chrome. One issue that is really frustrating me is that in Chrome, changing a CSS property seems to require clicking on it, deleting the current va ...

The nav bar in the React CSS is being populated with elements

Currently, I am in the process of developing a React app that includes a navigation bar. The issue at hand is that the content within my h1 tags and other elements are overlapping with the navigation bar - meaning that they are not properly contained withi ...

What are some methods to implement overflow:hidden for stacked images inside a div?

I currently have two images stacked on top of each other within a div element as shown below: <div class="container"> <img src="somepic.jpg" class="layer" /> <img src="otherpic.jpg" class="layer" /> </div> Styling is set u ...

Is there a way to shift a button within a div to the right while maintaining alignment?

After spending hours on this problem, I attempted to use "float: right" and successfully moved the button to the right. However, in doing so, the tag is no longer vertically centered. Can someone please assist me with this? Also, if there are multiple sol ...

Navigation menu automatically scrolls to the top instantaneously

Update: Apologies for the previous issues encountered with offline hosting. Upon transferring everything to the domain, the problem has been resolved. However, a lingering question remains about why the website loaded incorrectly when all files were kept i ...

How to create a gelatin-like effect on a rectangle using HTML5 canvas

Currently, I'm working on a platformer game project in JavaScript. The concept involves players as rectangles jumping on and off platforms. While the basic functionality is set up, I'm now aiming to incorporate a unique 'gelatine effect&apos ...

How to Handle Tab Navigation on a Mobile Website without Javascript?

My website primarily targets mobile devices, with tabs in the top navigation. Currently, these tabs are hard coded instead of utilizing Javascript. We want to ensure our site is accessible on all mobile devices, including those without Javascript support. ...

There is an unseen culprit lurking in the white void on the right side of the website

Does anyone else notice a mysterious blank space on the right side of my website? Even though the content spans 100% across the site and looks fine, there seems to be an extra margin when you scroll to the right, whether you're on a desktop or mobile ...

Guide for finding the current font of an HTML element

Imagine having a text element styled as follows: font-family: Arial, Verdana, Sans-serif; Is there a way to determine which specific font (Arial, Verdana, or Sans-serif) the browser utilized to display the text? ...

What steps do I need to take in order to arrange my cards into binary groups for PC viewing

Is there a way to display cards as binary groups for PC view? The layout looks fine on phone but the cards are all at the bottom when viewed on a computer. This is how it currently appears: https://i.sstatic.net/XBgJc.jpg I want the card layout to resem ...

Reposition the navbar nav to the top right corner of my website using Boostrap

I'm completely new to this subject. Currently, I've been following an online tutorial on HTML/CSS/Bootstrap. One thing I want to do is move the navbar to the top right of the page, like what you see in the image below. I manually added a mockup ...

SCSS: When hovering over one div, display a different div

My goal is to display the elements in another div when hovering over a specific div. However, my current code does not seem to be working as expected. At the moment, there is no response upon hover and it remains non-responsive. I would greatly appreciate ...

Disregard the stylesheet that has been provided

I'm currently working on a website using a template that includes a stylesheet. Unfortunately, the stylesheet is causing issues with elements I add such as Google Maps or other custom features on my site. Is there a way to prevent the following tag fr ...

Ensuring Consistent HTML5 Page Layout Across Various Browsers Using CSS

Hey everyone, I recently created an HTML5 page and utilized the <section> tag. However, I'm encountering issues with the CSS file I'm using. It seems to work perfectly on Firefox, but the layout is all over the place when viewed on Chrome a ...

Ways to distinguish between two labels having the same "for" attribute?

My HTML code is as follows: <label class="my-class" for="_something">Text Number 1</label> <label class="my-class" for="_something">Number 2 Text</label> I have two labels with the same class and identical "for" attributes. I am ...