Control the vertical center of the text in the HTML text box through CSS

Control the vertical center of the text in the HTML text box through CSS
When the height attribute of Text is defined, the text entered in the Text is not vertically centered. However, you can add CSS to control it and make the entered text vertically centered to make the web page more perfect.

Copy code
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>

After adding the two attributes of verticla-align and line-height, the text in the text box is vertically centered in the text box. It should be noted that line-height must be equal to height.

<<:  Analysis of the issues and solutions for repeated submission, repeated refresh, and backoff prevention

>>:  Detailed explanation of JavaScript's built-in Date object

Recommend

A brief discussion on the VUE uni-app development environment

Table of contents 1. Through HBuilderX visual int...

Solution to span width not being determined in Firefox or IE

Copy code The code is as follows: <html xmlns=...

React Router 5.1.0 uses useHistory to implement page jump navigation

Table of contents 1. Use the withRouter component...

What does mysql database do

MySQL is a relational database management system ...

W3C Tutorial (14): W3C RDF and OWL Activities

RDF and OWL are two important semantic web techno...

MySQL dual-machine hot standby implementation solution [testable]

Table of contents 1. Concept 2. Environmental Des...

Do not start CSS pseudo-class names with numbers

When newbies develop div+css, they need to name t...

Personalized and creative website design examples (30)

Therefore, we made a selection of 30 combinations ...

Conditional comments to determine the browser (IE series)

<!--[if IE 6]> Only IE6 can recognize <![...

Summary of tips for making web pages

Preface This article mainly summarizes some of th...

Practical record of optimizing MySQL tables with tens of millions of data

Preface Let me explain here first. Many people on...

Summary of uncommon operators and operators in js

Summary of common operators and operators in java...

Introduction to Javascript DOM, nodes and element acquisition

Table of contents DOM node Element node: Text nod...