How does the lineheight of Android and iOS work?

Source: Internet
Author: User

Lineheight on the PC side of the display is normal, but in the phone is very different, on the Iphone6, set the Lineheight, but the text above a few pixels, if you set the Lineheight in 35px button (with span), It is obvious that it is not horizontally centered.

Baidu Search, found that the phone rendering is not the same, but there is no use of CSS how to compatibility problems, so I would like to use JS to do a browser judgment, to do compatible

The JS code is as follows:

Detects the Android system or Iosvar client = function () {var system = {Ios:false,android:false};var U = navigator.useragent;if (!! U.match (/\ (i[^;] +;( U;)?  Cpu.+mac OS x/)) System.ios = True;if (U.indexof (' Android ') >-1 | | u.indexof (' ADR ') >-1) system.android = True;return {System:system};} ();//JQ Code $ (function () {//andriod and iOS line-height problem function lineheight (ele) {var lh = parsefloat (Ele.css (' Line-height ')); function iosline_heiht () {//If you do the project's Wow, here set the argument, the parameter is the trigger effect of the node element ele.css ({' Line-height ': (lh-1) + ' px ', ' Padding-top ': ' 1px '}); function Andriodline_heiht () {  ele.css ({' Line-height ': (lh-2.5) + ' px ', ' padding-top ': ' 2.5px '});} if (lh<35) {//when the line height is less than 35, do so, otherwise do not do so if (Client.system.ios) iosline_heiht (); if (client.system.android) andriodline_ Heiht ();}} Enter whether it is iOS or andriod$ (' #box '). html (' System.ios: ' +client.system.ios+ ' <br/> ' + ' system.android: ' + client.system.android);//Call Lineheight ($ ('. LH '));

The display results are as follows:

How does the lineheight of Android and iOS work?

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.