WebKit under Text

Source: Internet
Author: User
Tags empty

Article Introduction: clever use: empty solve the WebKit core browser text-indent bug.

Yesterday in the project encountered to use indentation in an input box, you want to use Text-indent first line indent 2 text. Then found that under WebKit, when the input box content is empty, the cursor position is not indented, or at the beginning of the line, enter any character, indentation is activated.

The HTML code is as follows:

1
<input
						type= "text"
						style= "Text-indent:2em"
						/>

View Demo

Here, whether it's an INPUT element or a textarea, or any other element that sets contenteditable= "true", this bug can be present.

IE versions, Firefox are normal, only chrome and Safari and other WebKit kernel browser only this problem.

Here baffled, but also tried a lot of methods, are ineffective.

Later and Xiao Li knife ,poor chat to this question, suddenly thought: Empty pseudo class, immediately test, can solve--although just curve simulation solution ...

1
Input[type= "text"]:EMPTY{PADDING-LEFT:2EM;}

And then submitted a bug list in the chromium community, wondering if it would be ignored.

Ps:opera here also have some minor problems, the input element indentation is normal, textarea element does not support indentation, contenteditable= "true" element and WebKit performance.

Http://www.qianduan.net/fixed-text-indent-in-webkit-editable-element-bug.html



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.