Styling Rules for WebKit Browsers

Is there a method to apply a particular CSS style for a div based on whether the user is accessing the page from a Chrome browser on a Desktop or an Android device?

.myDIV{
[if CHROME???] width: 280px; 
[if ANDROID???] width: 100%; 
}

Seeking guidance on how to detect Chrome or Android navigator using CSS.

Answer №1

Avoid checking specifically for Android compatibility in CSS - instead, focus on targeting screen sizes through the utilization of Media Queries. Embracing this approach is more effective than catering to individual browsers and is commonly referred to as responsive design, allowing designs to adapt seamlessly across various screen sizes.

.myDiv { width: 280px; }

@media screen and (max-width: 699px) {
  .myDiv { width: 100%; }
}

Answer №3

Although there isn't a specific CSS hack for older Android devices, I have discovered a workaround that will exclude iPads and iPhones (any iOS device). While this method may not be effective for older non-'ultra high definition' devices, it should work well for most modern ones.

Here's how to implement it:

/* Modern Android devices (Android 4.0+, Chrome 15+, Safari 5.1+, and Opera 14+) */

_:-webkit-full-screen, :root .selector { color:blue; }

You can test this on my live CSS hacks test page:

OR

This method works because iOS does not support the :-webkit-full-screen CSS pseudo-class, which is typically included in webkit distributions.

As of the time of writing, Safari is in version 8, and Chrome is in Development/Canary versions up to 41.

Enjoy exploring this hack!

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

Pop-up window for uploading files

Looking for assistance with my file uploading system. I am utilizing a unique purple button from http://tympanus.net/Development/CreativeButtons/ (Scroll down to find the purple buttons). Additionally, I am using a wide, short content popup feature availa ...

Positioning a div beyond the visible area without altering its original width, with the assistance of the Skrollr plugin

I'm currently experimenting with a parallax website using Skrollr. My goal is to achieve a curtain effect where two divs slide open left and right as I scroll down. The issue I'm facing is that when I scroll, the divs extend beyond the 100% widt ...

Enhancing the appearance of the CSS panel with Font Awesome icons

I need help adding a fontawesome or any other icon to my CSS3 based sliding panel button. The icon should change from open to close when clicked on. Any ideas on how to achieve this would be greatly appreciated! * { margin:0; padding:0; font-famil ...

delete local ios css style datetime input

I am facing an issue with the new ios 16 version in Safari where input time and input datetime are being displayed incorrectly. Is there a way to fix this problem? I have tried using -webkit-appearance: none; but it did not work. https://i.sstatic.net/em ...

Creating a dynamic multi-item carousel with Materialize (CSS) cards using data from a loop - here's how!

Using a for loop, the following code generates a list of cards. These cards are intended to be displayed in a carousel with 4 cards visible at once, and a next arrow button allows users to navigate through the next set of 4 cards. Materialize cards have ...

Utilizing MySQL and Json to Retrieve Data for AutoCompleteTextView: A Step-by-Step Guide

Attempting to implement the functionality in my application using the code snippet provided in MainActivity.java public class MainActivity extends Activity { public String data; public List<String> suggest; public AutoCompleteTextView au ...

Ways to verify if a JSON is empty on an Android device

I'm currently working on an Android app that retrieves data from a PHP JSON source. Successfully fetched the JSON data, but encountered a problem when the JSON response is empty, causing the application to stop. Therefore, I am looking for ways to d ...

Instructions for utilizing a contract class within an Android application

I am feeling a bit perplexed as I try to decipher the tutorial located here: http://developer.android.com/training/basics/data-storage/databases.html#DbHelper Here is my current code: public final class DatabaseContract { // This empty constructor preven ...

Having trouble with Chrome failing to use Cache for my .NET Project, I am experiencing an unexpected issue

It appears that Chrome is not adhering to cache directives for certain static files. Below is the relevant snippet from my web.config file as I utilize IIS: <location path="Scripts"> <system.web> <authorization> ...

Is the stylesheet connected but failing to load?

Updating an app from Rails 3.2 to version 4 has been mostly successful, but I am encountering issues with some of my stylesheets not being applied correctly. Checking the source code (ctr+U), everything appears to be linked properly: <!DOCTYPE html> ...

Incorporate DATE and TIME into RSS FEED for Android

I currently have an rss feed set up with 3 tabs, each tab pulling rss from a specific link. The rss is functioning properly, but I would like to include the DATE and TIME below each feed in this section of pictureLINK, similar to the layout shown in pictur ...

Ensure that the top of a div stays in place as the user scrolls, and spans the entire width of the div

My goal is to create a sticky or fixed position header inside a div with a list, but I'm facing an issue where it only sticks to the width of the text. If I expand the width to 100%, it takes up the size of the entire page: import styled from 'st ...

The hyperlink for making phone calls appears twice on an Android phone

When you click on the number, it will be displayed twice in the phone screen like this... 12345678910,12345678910 ...instead of just once... 12345678910 Take a look at the code snippet below: {#if order.salesRep} <div class="info"> ...

What are the various methods for incorporating icons and logos into website design?

Can anyone provide insights on the quality of logos and icons used in professional websites? I often create logos and icons using Illustrator, but when comparing them to icons on websites like those shown in the provided image and links, mine appear blurry ...

Is there a way to position my image and text side by side?

My current objective revolves around implementing a specific design, as illustrated in this image. The issue I'm encountering in my code pertains to the utilization of the bootstrap grid system for ease of layout. However, when I incorporate both tex ...

How to specify columns when storing data in a CSV file using Scrapy

As I scrape data from the web, I am facing an issue with my csv file where the links column is always displayed as the first column. How can I specify the placement of columns in the csv file? pName = response.css('#search .a-size-medium') ...

Implementing hover effect triggered by keyboard input

Is there a way to create a hover effect on a div when a specific key is pressed on the keyboard using jQuery? <div id="d-up" class="button"></div> Appreciate any help with this! Thank you. ...

Adjust the paragraph font size within the bootstrap stylesheet

We currently utilize the bootstrap v2 CSS and are interested in globally increasing the font size by a point or two. I am wondering if this adjustment is a straightforward modification within the CSS file or if it requires a more complex approach. After a ...

Ways to ensure the image stays fixed even as the screen dimensions fluctuate. HTML/CSS

Struggling to create an HTML header with a title and image positioned on the right side, but facing issues with the image shifting over the title when screen size changes. How can I ensure the image stays in place? Have tried various solutions without succ ...

Tips for creating CSS styles for a selected input field

I seem to be stuck in a situation where my screen looks similar to the screenshot provided. There are four input elements that I would like to have bordered just like in the image, complete with a circled tick mark. I've managed to create these four i ...