On android devices with high density screens (devicePixelRatio of 1.5) the borders of html elements have wrong border width.
The two boxes here: jsbin sample, appear correctly on the desktop
but on the android - both in chrome and the stack browser - they look like this:
now i understand why they look like this, but i cannot find any CSS solution - only js.
the js solution would be to change the width and height of the elements to be odd as well as the top/left properties.
If you've set the shorthand border property in CSS and the border is not showing, the most likely issue is that you did not define the border style. While the border-width and border-color property values can be omitted, the border-style property must be defined. Otherwise, it will not render.
We can specify the no border property using CSS border: none, border-width : 0, border : 0 properties. Approach 1: We will give border-color, border-style properties to both headings, for showing text with border and no-border. For no border heading, we will use the border-width : 0 which will result in no border.
There is no standard solution, too bad.
You can make the next tricks to avoid an inconsistent displaying of borders with 1px width.
border-color: rgba(169, 0, 52, 0.5)
I tested this on Android 4.4.2 Chrome & Yabrowser browsers. Works fine!;make width/height of bordered element odd, and shift element position. Here you need to experiment and use JS, saying like:
$('div.elemWithBadBorders').each(function(){
var $el = $(this);
var width = $el.width();
if(width % 2 == 0){
$el.css('width', (width+1)+'px');
}
});
Disable borders if showed on Retina displays or other hires screens. You need to use media query in css like this:
@media (-webkit-min-device-pixel-ratio: 1.5) {
div.elemWithBadBorders {
border: none;
}
}
where 1.5
is pixel density. On Retina displays it appears as 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With