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

CSS border adds four corners implementation code

1.html <div class="loginbody"> &l...

JavaScript canvas realizes the effect of nine-square grid cutting

This article shares the specific code of canvas t...

Summary of several commonly used CentOS7 images based on Docker

Table of contents 1 Install Docker 2 Configuring ...

HTML table_Powernode Java Academy

To draw a table in HTML, use the table tag tr me...

How to configure ssh to log in to Linux using git bash

1. First, generate the public key and private key...

Example code of how to implement pivot table in MySQL/MariaDB

The previous article introduced several methods f...

Detailed example of reading speed of js objects

1. Accessing literals and local variables is the ...

Detailed explanation of the use of Vue3 state management

Table of contents background Provide / Inject Ext...

CSS element hiding principle and display:none and visibility:hidden

1. CSS element hiding <br />In CSS, there ar...

How to use Cron Jobs to execute PHP regularly under Cpanel

Open the cpanel management backend, under the &qu...

How to underline the a tag and change the color before and after clicking

Copy code The code is as follows: a:link { font-s...

Introduction to useRef and useState in JavaScript

Table of contents 1. useState hook 2. useRef hook...