About the invalid line-height setting in CSS Let's write this string of code first: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> .head{ height: 100px; text-align: center; line-height: 100px;/* Set the line height to center the font*/ background: #333;/* Set the entire background to black to make it easier to see the font*/ color: red; font:700 18px simsun;/* Set the font*/ } </style> </head> <body> <div class="head"> Hello, Southwest Petroleum University. </div> </body> </html> Then open it in the browser to see the effect: We found that in the vertical direction, the font is not displayed in the middle of the box. Then we put the statement that sets the line height below the statement that sets the font: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> .head{ height: 100px; text-align: center; background: #333;/* Set the entire background to black to make it easier to see the font*/ color: red; font:700 18px simsun;/* Set the font*/ line-height: 100px;/* Set line height*/ } </style> </head> <body> <div class="head"> Hello, Southwest Petroleum University. </div> </body> </html> Then open it with your browser: The font successfully jumped to the middle~~~~~ Summary: When setting the line height with CSS, the line-height attribute must be below the font, otherwise it will be invalid! The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: JavaScript to achieve magnifying glass effect
>>: Docker installation and deployment example on Linux
MySQL replace and replace into are both frequentl...
In daily operation and maintenance work, backup o...
1. System installation package yum -y install mak...
This article shares the specific code of js to ac...
Table of contents 1. Plugins 2. Interlude 3. Impl...
Preview versions of Safari (Technology Preview 10...
What is text wrapping around images? This is the ...
Table of contents Parent component listBox List c...
1: Tag selector The tag selector is used for all ...
How to write judgment statements in mysql: Method...
Recently, I encountered many problems when instal...
Resource merging and compression for two purposes...
VMware vSphere is the industry's leading and ...
Preface Backup is the basis of disaster recovery....
This article example shares the specific code of ...