Come see the media Rule on display (viewable on a mobile phone)!

Seeking a solution to the issue of making the "IN PC" item visible only on computer screens and not on mobile phones. This menu item continues to display on mobile devices, despite efforts to resolve the problem. Any insights on where the problem lies and how to address it would be greatly appreciated.

Thank you.

@media only screen and (max-width:768px) {.hide-phone { display: block; } }

https://i.sstatic.net/f04K1.jpg

Answer №1

Following updates were made after reviewing your comment:

I have analyzed your code to identify any potential issues or improvements.

  1. It is recommended to have only LI as direct children of UL, instead of having a div directly under UL.

For example, consider this structure:

<ul class="nav sidebar-inner" id="sidebar-menu">
    <li class="has-sub">
    </li>
    <li class="has-sub"> 
    </li>
    <li class="has-sub">
    </li>
    <li class="has-sub">
    </li>
    <li class="has-sub">
    </li>
    <li class="has-sub desktop">
    </li>
    <li class="has-sub mobile">
    </li>
    <li class="has-sub">
    </li>
</ul>

The LI with class "desktop" should be displayed on desktop only, while LI with class "mobile" should be visible on mobile devices.

To achieve this, you can write CSS accordingly. For example, hide mobile by default and show it on mobile only, while hiding desktop on mobile screens:

.mobile {display: none;}
@media(max-width:767px){
    .mobile {
        display: block;
    }
    .desktop {
        display: none;
    }
}

NOTE: The media point of 767px used in the example can be adjusted based on your requirements. Ensure to align your CSS with the correct HTML structure for desired functionality.

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

The behavior of Datatables varies depending on the screen resolution

In my data table, there are numerous entries with child tables on each row of the main table. I am currently in the process of incorporating this type of functionality into my table, with a few modifications to create a table within the child row. You can ...

Using jQuery to decrease the transparency of an image when the mouse hovers over it

I'm trying to set it up so that when you hover over an image, the opacity decreases by half. I know I must be making a simple mistake here, but I just can't figure out what it is. Any suggestions would be greatly appreciated. http://jsfiddle.net ...

Designing a blurred and distinct margin with the hover effect in html and css

Hey there, I've been attempting to replicate the hover effect on the buttons located on the left-hand side of this site , but unfortunately, I haven't had much success. The effect seems to involve a shift in margin and an unevening of margins tha ...

The :focus pseudo-class is failing to target the input element

I'm dealing with a simple input field of type text: <input matInput type="text" placeholder="{{placeholder}}" class="input-field" [ngClass]="{'error': hasErrors}" [readonly]="isReadonly&quo ...

Retrieve the width of an element once the browser has finalized its dimensions

I am facing an issue with centering a pop-up box perfectly within the window using CSS properties. The code for the pop-up box styling is as follows: #pop_up { position: fixed; display: inline-block; border: 2px solid green; box-shadow: 0p ...

I'm attempting to execute a piece of code that retrieves a status count from a dataframe, the output of which will be displayed above my pandas html table

#Here is an example of a dataframe: import pandas as pd import numpy as np data = [['001', 'Completed'], ['002', 'In Process'], ['003', 'Not Started'], ['004''Completed ...

Ensure Focus Retention Upon Clicking Inside Iframe with li a:focus

How can I prevent my ul.SideNav_Main li a:focus class from losing focus when I click on the iframe or elsewhere on the page? Shouldn't it maintain focus until I click on another URL in the list? Is it possible to solve this issue with just CSS, or wo ...

Is it possible to position the Sprite image to the right of the anchor tag?

I have a CSS sprite image that is functioning correctly, but I am encountering an issue where the image is displaying on the left side of the anchor tag's text instead of the right. You can view the sprite image here. Expected result: [Mylinktext]&l ...

Guide on creating a toggle effect for a div with querySelector and addEventListener

I utilized the email and password divs provided by Bootstrap. The CSS for the id dropdownlogin includes display: none; in this post, I hope that I have shared adequate information. <script> document.addEventListener('DOMContentLoaded', ...

What is the purpose behind certain developers specifying font size twice using different units?

When creating website themes, I often come across developers defining properties twice with different units. For example: body, button, input, select, textarea { color: #404040; font-family: sans-serif; font-size: 16px; font-size: 1rem; ...

Creating a resilient CSS: DOM for seamless printing in PDF or on physical printers

I need help with formatting a list of col-6 elements (bootstrap) inside a row element so that the content of each block remains intact in a pdf preview generated using print(). I attempted to use various css properties like page-break and break as suggeste ...

When attempting to execute a function when a hidden div is not displayed, JQuery encounters an

I'm currently attempting to modify the text color of the h2 title with the id ticketSearchTitle when the ticketSearch div is not visible. However, the code I have been using to achieve this seems to cause issues (such as the absence of a pointer icon ...

Rails: How come my personalized stylesheet isn't taking priority over the font family?

I have included the Skeleton boilerplate css in my application from this source. It can be found within the directory app/assets/stylesheets. app/assets/stylesheets ├── application.css ├── custom.scss ├── normalize.css └── skeleton ...

The x-axis values in Amchart are transitioning rather than shifting

I'm facing an issue with my x-axis values as I'm using real-time amcharts. The x-axis values change every 3 seconds, but instead of smoothly moving, they abruptly change to the next value. I would like it to slide smoothly like this example: htt ...

Expand <a> to occupy the <li> element within the menu

Encountering a bit of a challenge... Is there a way to expand my <a> elements to completely fill the <li> containers they are placed in? I'm aiming to enhance the accessibility of the links for easier clicking. Check out my jsFiddle: htt ...

When clicking, populate the content of another div in a vertical top-to-bottom fashion

I am in the process of creating a functionality where clicking on one element will fill another element's content from bottom to top. Although I have managed to make it work on hover, the same functionality is not triggered when clicking on the eleme ...

Pressing the enter key in the input field will cause the multistep progress bar to update its

When I press Enter in each input field, I want the multi-step progress bar to dynamically update by adding the 'is-active' class to the next list item and removing it from the previous one. How can I achieve this using jQuery? ...

Ways to incorporate margins into text on PDF pages produced by Puppeteer without altering the background color

I am currently using puppeteer to generate PDFs that contain dynamic content. My goal is to include margins/padding above and below the text on consecutive pages. Unfortunately, when I try to add margins with the property margin: { top: "1cm", bottom: "1 ...

Achieve a full vertical span of the Bootstrap 5 grid row to encompass all of its content

How can I ensure that a Bootstrap 5 grid row expands to fit its entire content vertically? Adding a label element causes the content of the first row to overlap with the second row in the example provided below. <!doctype html> <html lang="en ...

Using Rails to reference an image in CSS

My application on Heroku, built with Rails, features a striking image as the background on the landing page. Since Heroku's file system is read-only, I made the decision to store these images (selected randomly) on AWS S3. In my .css(.scss) code, the ...