Guide to implementing personalized CSS on WooCommerce product pages specific to mobile screen resolutions

As a beginner in wordpress, I am looking to customize the CSS of my single product page specifically to relocate the "Sale" icon. Despite trying the code below in custom CSS, no changes are being reflected.

@media only screen and (max-width: 767px){
.single-product .woocommerce .has-product-nav span.onsale {
    top: 7rem !important;
    margin-top: 0px;
}
}

Answer №1

In my view, it is generally more efficient to establish the basic css rules required for your class and then adjust them for different screen sizes such as mobile, tablet, and larger desktops.

The issue you may be encountering could be due to another css rule overriding the one for the mobile version. Try removing the !important from the desktop version's .single-product if applicable.

By doing this, the problem should be resolved.

 /* Desktop Version */
 .single-product .woocommerce .has-product-nav span.onsale {
    top: 7rem;
    margin-top: 0px;
  } 

 // Define styles for portrait orientation on mobile
 @media screen and (max-width: 767px) and (orientation:portrait) {
    .single-product .woocommerce .has-product-nav span.onsale {
        top: 5rem !important;
     }
   }

 // Adjust styles for landscape orientation on mobile
 @media screen and (max-width: 767px) and (orientation:landscape) {
    .single-product .woocommerce .has-product-nav span.onsale {
        top: 4rem !important;
     }
  }

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

Retrieving form data from previous page using PHP mail function

Currently, I have a form that needs to be filled out on one PHP page with the following structure: <p> <label for="first_name">First Name: </label> <input type="text" size="30" name="first_name" id="first_name"/> </p> < ...

Vertical Image Alignment in Bootstrap 3

Looking for some help with a basic HTML structure here. I have a single row divided into two columns, each containing an image of the same size. What I need is to center one image both horizontally and vertically in each column. <div class="containe ...

What is the best way to add hover effects to the linked images on my Wordpress post, especially since they are icons?

Is there a way to add hover effects to linked images within a WordPress post? Below is the code snippet embedded in the WordPress post: <p> <a href="https://www.pinterest.com/meganpolk/?eq=miss&amp;etslf=2961"> <img class=" ...

Click on the print icon in the modal window

I have been working on a receipt generator for a client. The client can add payment receipts using the "Add" button, and upon submission, they have the option to convert it to PDF or print it. However, there seems to be an issue with printing as the text f ...

Overlay one image on top of another

Recently, I've been working on this code snippet. I am attempting to center the profile picture even when the screen width is reduced. The issue lies with using position:absolute, preventing margins:auto from functioning properly. As a workaround, I ...

Fixing a lengthy text issue in the breadcrumbs code

My breadcrumbs break when I enter a long text. Any suggestions on how to fix this issue? Feel free to check out this Fiddle for reference: http://jsfiddle.net/neodjandre/pbEpG/ .breadsmall ul{margin:0px;} .breadsmall ul li{display:inline-block;height:20p ...

Ways to ensure that the height of a div remains consistent across all scenarios

https://i.sstatic.net/6LY1C.png Below is the code snippet, which utilizes bootstrap. I need to set a fixed height for a div that is populated dynamically from a database. The goal is to maintain the height of the div regardless of the content length. If ...

Utilizing CSS nth-child on dynamically generated HTML in Angular

Ensuring that the columns are floated to the left without large gaps between rows is my current challenge. Here's the HTML structure I'm working with: <div class="row hide-for-small"> <div ng-repeat="module in modules"> ...

Input tag styled in a center-aligned word document format

My Desired Text Alignment: I want the text to be centered horizontally at the top of the input. Words should break after hitting the internal padding, similar to how document creation software like Google Docs works with center alignment. Current Alignme ...

When clicked, the menu smoothly fades in, but unfortunately, the fade-out effect is not functioning as intended

My website has a "hamburger" icon button that, when clicked, reveals the menu with a fading effect. However, I encountered an issue where trying to apply the fadeOut effect to another icon/button within the menu did not work as intended. The menu remained ...

Setting a background image in vanilla-extract/css is a straightforward process that can instantly enhance

I am brand new to using vanilla-extract/CSS and I have a rather straightforward question. I am attempting to apply a background image to the body of my HTML using vanilla-extract, but I am encountering issues as I keep getting a "failed to compile" error. ...

Is there a way for me to implement this code to achieve the functionality shown in the demo link

$('select').change(function() { var sum = 0; var sum = parseInt($('select[name="bathrooms"]').val() * 25) + parseInt($('select[name="bedrooms"]').val() * 8); $("#sum").html(sum); }); <script src="https://ajax.googleap ...

Combining Bootstrap and @material-ui for a better UI experience!

Is there a way to apply Bootstrap classes to @material-ui components? For example, I am attempting to create a button and style it using both 'btn' and 'btn-primary' from Bootstrap. import { makeStyles } from "@material-ui/core&quo ...

What is the best way to arrange three identical boxes next to each other, all of the same size

Imagine having a container with the following dimensions: .container { width: 960px; margin: 0 auto; height: 500px; } Now, envision wanting to add three boxes in the center aligned horizontally with these specifications: .box1 { background-color ...

Hovering over elements without triggering their appearance

My CSS includes hover conditions for specific divs, such as a parent relationship transition (#playing-field:hover #cont2) and a self transition (#piccont2:hover), but they don't seem to be working properly. The only hover effect that works is the a:h ...

Develop and arrange badge components using Material UI

I'm new to material ui and I want to design colored rounded squares with a letter inside placed on a card component, similar to the image below. https://i.stack.imgur.com/fmdi4.png As shown in the example, the colored square with "A" acts as a badge ...

Issue with bootstrap 4 CDN not functioning on Windows 7 operating system

No matter what I do, the CDN for Bootstrap 4 just won't cooperate with Windows 7. Oddly enough, it works perfectly fine on Windows 8. Here is the CDN link that I'm using: <!doctype html> <html lang="en> <head> <!-- Req ...

The links are displaying on separate lines instead of being inline

There is a tags section on the blog detail page. The html code for it is as follows: <td class="tags"> <a href="">tag1></a>, <a href="">tag2</a> </td> However, the tags are appearing on separate lines instead of in ...

Footer that is adhered to the bottom of the page with a

Can a sticky footer with a transparent background be achieved without a content background (.wrapper) underneath it? I found this resource: ...

Customize the keyboard on your iPod by replacing the default one with a

Looking to customize the iPOD keyboard to only display numbers, similar to a telephone keypad: https://i.stack.imgur.com/X0L3y.png The current iPOD default keyboard looks like this: https://i.stack.imgur.com/VykjU.png ...