iOS implements several 0.5px methods, Android devices are also practical, Android and iOS implement thin border

Source: Internet
Author: User

Determine the iOS version, set a global style name hairlines, by using the style name to add styles to different versions of iOS, iOS version of the different for the 0.5px display difference is very large, the same device also shows a variety of effects.
Android does not need to judge the version, you can skip the JS judgment.
<script type= "Text/javascript" >
//js in head area .if(/IP (HONE|OD|AD)/. Test (navigator.useragent)) { varv = (navigator.appversion). Match (/os (\d+) _ (\d+) _? ( \d+)?/), Version= parseint (v[1], 10); if(Version >= 8){
iOS 8 or later Document.documentElement.classList.add (' Hairlines ') } if(Version >= 9) {Document.documentElement.classList.add (' Hairlines2 ') } } </script> CSS styles can be written like this:. Hairlines. go-rt{border-Bottom:none;} make 1px border thin line by pseudo-class, border border set to none;
/*** the width and height of the pseudo-element by 200% to be covered with the div widths and heights ***/

1, set the pseudo-elements of the border implementation of thin 0.5px
Disadvantage: The child elements of the defined element are also automatically added to the pseudo-class line. So you need to be careful when you use it.
. Hairlines. Gray-btn:before{
 content:"; Width:200%; padding:3px; Height:200%; border:1px solid #ccc; Position:absolute; Top:0; Left: 0; -webkit-box-sizing:border-Box; Box-sizing:border-box; -webkit-transform:scale (0.5); Transform:scale (0.5); -webkit-transform-origin:0 0; Transform-origin:0 0;}

2, through the height of the pseudo-element to achieve 0.5px. Hairlines. Mine-pic:before{content:'; Width:200%; Position:absolute; Top:0; Left: 0; Right:0; -webkit-transform:scale (0.5); Transform:scale (0.5); -webkit-transform-origin:0 0; Transform-origin:0 0; height:1px; Background-color: #ccc; }
3, through the shadow implementation of iOS o.5px, some devices will have a shadow
#button {    background-image:linear-gradient (180deg, #ccc, #ccc 50%, Transparent 50%),  linear -gradient (270deg, #ccc, #ccc 50%, Transparent 50%),  linear-gradient (0deg, #ccc, #ccc 50%, Transparent 50%),  linear-gradient (90deg, #ccc, #ccc 50%, transparent 50%);  Background-size:100% 1px,0px 100%, 100% 1px, 0px 100%;  Background-repeat:no-repeat;  Background-position:top, right top,  bottom, left top;  padding:10px;   0;  Overflow:hidden;    

iOS implements several 0.5px methods, Android devices are also practical, Android and iOS implement thin border

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.