Solution to inconsistent display of cursor size in input box

Solution to inconsistent display of cursor size in input box
The cursor size in the input box is inconsistent

The difference between IE7 and Chrome is very obvious

Let's first look at the cause of the problem: the Chrome browser sets the cursor height in the following principle: when there is no content, the cursor height = the value of the input's line-height; when there is content, the cursor moves from the top of the input to the bottom of the text.

OK, now that we know the reason, we will take some corresponding measures. Tried two ways to do it:.

Method 1: Set the line-height value to the same as the font size; if the height is not reached, use padding to support it;

Method 2: Do not set line-height for Chrome, it will automatically center the text, and set the line-height value for IE to ensure that the text is vertically centered. Please note here that if line-height and other values ​​are set in the reset style file, please reset line-height, you can use line-height:normal. For details, please look at the search box on the Tencent Hollywood page.

Specific css:

Copy code
The code is as follows:

height: 34px;
font-size: 12px;
line-height: normal;
line-height: 34px\9;

<<:  A brief analysis of CSS3 using text-overflow to solve text layout problems

>>:  Learn more about the most commonly used JavaScript events

Recommend

mysql5.7 installation and configuration tutorial under Centos7.3

This article shares the MySQL 5.7 installation an...

Summary of twelve methods of Vue value transfer

Table of contents 1. From father to son 2. Son to...

How to build a standardized vmware image for kubernetes under rancher

When learning kubernetes, we need to practice in ...

Summary of MySQL character sets

Table of contents Character Set Comparison Rules ...

Realization of real-time file synchronization between Linux servers

Usage scenarios For existing servers A and B, if ...

CentOS 7.2 builds nginx web server to deploy uniapp project

Panther started as a rookie, and I am still a roo...

Some summary of MySQL's fuzzy query like

1. Common usage: (1) Use with % % represents a wi...

Founder font library Chinese and English file name comparison table

Founder Type Library is a font library developed ...

An audio-visual Linux distribution that appeals to audiophiles

I recently stumbled upon the Audiovisual Linux Pr...

JavaScript to implement simple carousel chart most complete code analysis (ES5)

This article shares the specific code for JavaScr...

Implementation of new issues of CSS3 selectors

Table of contents Basic Selector Extensions Attri...

Several things to note when making a web page

--Homepage backup 1.txt text 2. Scan the image 3. ...

WeChat applet custom bottom navigation bar component

This article example shares the specific implemen...