You can use the :before, :after and content attributes in css to add horizontal lines on both sides of the text; the syntax "E:before,E:after{content:"";flex:1 1;border-bottom :2px solid;}", E is an element containing text.
#The operating environment of this tutorial: Windows 7 system, css3 version, Dell G3 computer.
Tutorial recommendation: css video tutorial
css method of adding horizontal lines on both sides of text
In css, This can be achieved using the :before, :after selectors and the content attribute.
:The before selector inserts content before the selected element, and the :after selector inserts content after the selected element.
The content attribute is used with the :before and :after pseudo-elements to insert generated content.
Example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> h4 { display: flex; flex-direction: row; } h4:before, h4:after { content: ""; flex: 1 1; border-bottom: 2px solid #000; margin: auto; } img { height: 100px; width: 100px; border-radius: 50%; } </style> </head> <body> <h4>PHP中文网</h4> </body> </html>
Rendering:
Programming Teaching ! !
The above is the detailed content of How to add horizontal lines on both sides of text in css. For more information, please follow other related articles on the PHP Chinese website!