How to make CSS visible only for Android phone UC browser

Is there a way to make some CSS rules only visible to Android UC Browser Android?

+3


source to share


1 answer


Take a look at this article: CSS: User Agent Selector

Basically when you use this script:

var b = document.documentElement;
b.setAttribute('data-useragent',  navigator.userAgent);
b.setAttribute('data-platform', navigator.platform );
b.className += ((!!('ontouchstart' in window) || !!('onmsgesturechange' in window))?' touch':'');

      

You can now use CSS to target any browser / version.



So for Android UC I looked here to see the Android UC user agent strings and they all contained the text 'UCBrowser' so we can do the following:

FIDDLE

html[data-useragent*='UCBrowser'] .someRules
{
    visibility: visible;/* or display:block etc */
}

      

+1


source







All Articles