by <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> #next-button{ height: 54px; text-align: center; color: #fff; background: #e2231a; line-height: 54px; font:16px "Microsoft YaHei","Hiragino Sans GB"; cursor: pointer; margin: 0 auto; width:400px; } </style> </head> <body> <div id="next-button">Next</div> </body> </html> In it, we set the width, height, background color, font, and horizontal and vertical centering, however, we get this effect:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> #next-button{ width:400px; height: 54px; text-align: center; color: #fff; background: #e2231a; font:16px/54px "Microsoft YaHei","Hiragino Sans GB"; cursor: pointer; margin: 0 auto; } </style> </head> <body> <div id="next-button">Next</div> </body> </html> , it can be centered vertically. The reason is that if line-height and font are included in the style declaration list, line-height is invalid and must be used together with font. As long as there is no font in the style declaration, you can use line-height to set the vertical center of the text. This concludes this article on the solution to the problem that fonts in HTML cannot be vertically centered even after using line-height. For more information about line-height not being able to be vertically centered, please search 123WORDPRESS.COM’s previous articles or continue browsing the related articles below. We hope that everyone will support 123WORDPRESS.COM in the future! |
<<: CSS new feature contain controls page redrawing and rearrangement issues
>>: Brief introduction and usage of Table and div
Preface In case of application bug or DBA misoper...
Table of contents Preface: accomplish: Summarize:...
I won't go into details about how important b...
Let's look at the case first. Use vue+swiper ...
About let to avoid problems caused by closure Use...
Effect Need environment vue elementUI Drag and dr...
We usually use the <ul><li> tags, but ...
This article shares the specific code of jQuery t...
Slideshows are often seen on web pages. They have...
Common usage of Regexp in Mysql Fuzzy matching, c...
During the project development yesterday, I encoun...
I recently reviewed some CSS-related knowledge po...
Use HTML CSS and JavaScript to implement a simple...
Use JOIN instead of sub-queries MySQL supports SQ...
Previously, the images we used were all pulled fr...