Google Chrome input is set to line-height and the cursor becomes as high as input

Source: Internet
Author: User

When the height and line-height of Google Chrome input are set to the same value that is higher than the default height, when the input control receives the focus and no input is entered, the The cursor in input fills the entire input control (if Padding-top or Padding-bottom is set below the height of the entire control), but the cursor height reverts to the height of the font immediately after the entry, and the case code is as follows, so how do you solve this problem?

<! DOCTYPE html>

Google Chrome input Line-height Bug Solution

      • Remove the Inline-height attribute, but this causes the cursor of input in the Ie6/7/8 browser to be offset to the upper left of input, in the standard browser (specifically Google Chrome, Firefox, Opera, Safari, IE + +), If you set the height for input without setting line-height, the browser automatically aligns the content in input with the cursor vertically, and the height of the cursor is the same as the height of the word. IE8 and earlier non-standard, the height and line-height must be set to the same value in order to make the contents of input vertically aligned, so fix a browser, but damaged more browsers, it is not worth the candle, see the following perfect solution.
      • Add a style input[type= "text"]:focus{line-height:normal}, which causes the input cursor in IE8 to be offset to the upper left of input, IE6/7/9 and the updated version are displayed normally. As long as you add a CSS hack, you can solve the problem, to achieve all major browser compatibility: input[type= "text"]:focus{line-height:normal; line-height:2.4em\9;}, The 2.4em is the originally set value.
      • Google Chrome 39 has fixed this bug, which is the perfect solution.

Google Chrome input is set to line-height and the cursor becomes as high as input

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.