Detailed explanation of controlling the vertical centering of text in HTML text boxes through css

高洛峰
Release: 2017-03-06 17:11:23
Original
2268 people have browsed it

When the height attribute of Text is defined, the text entered in Text is not vertically centered, but it can be controlled through CSS. There is a good example below, you can refer to it. When the height attribute of Text is defined, the text entered in Text is not vertically centered. However, you can add CSS to control it so that the entered text is vertically centered to make the web page more perfect.

The code is as follows:

<html> 
<head> 
<style type="text/css"> 
#text { 
height:20px; 
vertical-align:middle; 
line-height:20px; /*line-height must be equal to height*/ 
} 
</style> 
</head> 
<body> 
<table> 
<input type="text" id="text"> 
</table> 
</body> 
</html>
Copy after login


After adding the two attributes verticla-align and line-height, the text in the text box will be vertically centered in the text box. To Note that line-height must be equal to height.

For more detailed information on controlling the vertical centering of text in HTML text boxes through css, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!