Hide elements on desktop viewport using media queries

If you want to see the code I'm using on my live site, visit www.randolphlibrary.org/mobilesite.htm

In short: How can I implement a list-view style for users with a viewport of max-width 768px so that it caters to mobile users?

My plan was to add this code to the header:

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css" media="(max-width: 768px)"/>

<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>


<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>

However, the challenge lies in getting the mobile device to prioritize this jQuery stylesheet over the default CSS already in place.

Someone suggested creating a media query with @media= "(max-width: 768px) { display:none; } but it didn't work as expected.

This seems like a simple problem, yet I'm struggling to find a solution. Even manually adding display:none; to the body in the default CSS isn't effective.

Any advice would be greatly appreciated as I aim to make our small town library more appealing to the younger generation glued to their phones.

UPDATE: My mentor mentioned that for a basic jQuery Mobile page, we need three files in the head section: a CSS file for jQuery functionality, a Javascript file enabling jQuery, and another JavaScript file supplementing the core jQuery functions for mobile devices (jQuery Mobile).

With the inclusion of the above three files, I thought I had everything set up correctly. However, I still encounter some issues.

Answer №1

Do you mind sharing some of your JQuery code with us? I believe I can offer assistance, but it would be helpful to see the context in which you are working. Upon initial inspection, it appears that you could potentially address this issue within the JQuery file itself by specifying when the code should execute based on the window width. Would you like to explore this approach further?

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 CSS transition for a DIV on an iOS Safari browser is experiencing a lag

In an attempt to optimize CSS transitions in the IOS Safari browser, I decided to use the transform: translate() property instead of changing the left property like other suggestions. Unfortunately, this approach did not yield the expected results as the ...

Tips on dynamically looping the formcontrolname and implementing validation strategies

Looking for a way to validate multiple looping of dynamic formControlName="xxx" in select field. Check out my HTML code: <ul *ngFor="let detaillist of stressli.stresstabdetails;"> <li> <div class="form-container"> ...

Tips on placing a white background behind fa-3x (Font-awesome) icons

I am facing challenges while trying to customize the background behind my font-awesome icons. My goal is to create a white background that does not extend beyond the actual icon itself. Currently, the result looks like the image below: https://i.sstatic. ...

Fixed positioning upon scrolling begins prior to reaching the uppermost point (top div)

Currently, I have implemented a feature where #filter (the white select list in my sidebar) becomes fixed when it reaches the top of the page and stays there while scrolling until it reaches the footer and is released. However, I encountered an issue wit ...

Discovering the CSS code for customization

As a beginner, I apologize in advance for any silly questions ˆˆ I am currently working on a website using bootstrap. Everything is functioning correctly, but I am struggling to override some CSS styles. In the image provided, you can see how I used the ...

Issues with HTML Email display

Hey there, I am facing an issue while trying to send an HTML email. I am aware that Outlook does not support a lot of CSS formatting, but I can't figure out why this simple setup is breaking. Is there a quick fix or alternative solution? Take a look a ...

The issue with material-ui 0.15.2 is that it applies extra vendor-prefixed styles on the server side but not on the client side, resulting in warnings in React 15

I have set up my project with the following configurations: react is at version 15.2.1 material-ui is at version 0.15.2 I am using express and universal-router for server-side rendering Every time I include a material-ui component, I encounter this erro ...

Utilizing HTML list elements in conjunction with a switch statement, and connecting the list directly to a database for

Hey there, I'm interested in learning how to access HTML elements and use them within switch statements. <div id="hori"> <ul> <li><a href="#">Aerospace</a></li> <li><a href="#">Automotive</a>< ...

Display the div with the specific id when it is clicked using jQuery

How can I make one div appear when another div is clicked? Specifically, I want #musicinfo to appear when #music is clicked. Below is the CSS styling for these elements: #music { float:left; height:25px; margin-left:25px; margin-top:25px ...

Troubleshooting a CSS problem on a table filled with images - See attached screenshots for

I've been working on a project involving my phpmyadmin database generating a series of 6 images on my website. I've placed them in a table, but now I'm facing some challenges - even though it seemed simple at first! The goal is to display t ...

Adjusting Images and Icons' Sizes Automatically on a Single Line

Imagine a row of social media icons/images (like Facebook, Twitter, LinkedIn) displayed together. How can I ensure that when I add more icons/images to this row, their sizes adjust automatically to stay on the same line instead of moving to the next one? I ...

Are there any known browser compatibility issues with using "./" (dot slash) before HTML files?

Within the realm of shells, using ./ to indicate the current directory is quite common and generally not perceived as risky when specifying a path. On the other hand, in HTML coding, it's typical to omit ./ and instead directly specify the file name. ...

Which Express.js template allows direct usage of raw HTML code?

I am in search of a template that utilizes pure HTML without any alterations to the language, similar to Jade but keeping the HTML as is. The reason behind this inquiry is: I prefer the simplicity and clarity of HTML I would like to be able to easily vi ...

The ValueError message indicated that the data provided contained 282 columns, while only 60 columns were expected

I encountered the following error message: ValueError: 60 columns passed, passed data had 282 columns. How can I resolve this issue? You can find more information on the problem by visiting the following page: . Once you are on that page, click on Q1 and ...

Issues arise with the functionalities of FireFox related to transformations and transitions

I've been working on my CSS and here is what I have: img.buttonImg { -webkit-transition: all 0.5s ease-in-out; -moz-transition: all 0.5s ease-in-out; -o-transition: all 0.5s ease-in-out; -ms-transition: all 0.5s ease-in-out; transition: ...

` `Spinning graphics and written content``

I am looking to create a dynamic element on my website where an image and corresponding text block rotate every few seconds. An example of what I am envisioning can be seen on this website: While I know how to implement a javascript for rotating images, I ...

The functionality of using variables in conjunction with the .insertAfter method appears to be

As a novice coder with limited English skills, I apologize in advance. Here is the CSS code snippet I am working with: #wrapper{ width: 200px; height: 300px; border: solid 1px #000; overflow: visible; white-space: nowrap; } .page{ ...

Imagine a complex JSON structure with multiple levels of nesting

Take a look at this JSON data : { department_1 : [{ id : 1, name = Joe Smith, email : <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="660c150b0f120e2613150048030213">[email protected]</a>}, ...., { id : 500, name ...

What is the best way to define coordinates or set margins for the autoTable component in jsPdf when using React js?

While working with the jsPdf library to create a PDF in React, I am encountering an issue where I am unable to set margins for the autoTable when there are multiple tables on a single page. Below is the code snippet: import React from "react"; ...

Change to a dark theme using React hooks in typescript

Hello, I am new to React and English is not my first language, so please excuse any mistakes. I have been trying to enable a dark mode feature on my website. Most examples I have found involve toggling between dark and light modes where you need to specify ...