1. The vertical-align property achieves the following effect: The vertical-align property sets the vertical alignment of an element. This property defines the vertical alignment of an inline element's baseline relative to the baseline of the line in which the element resides. Negative length values and percentage values are allowed. <div class="header"> <span class="line"></span> <span class="text">Text in the middle, horizontal lines on both sides</span> <span class="line"></span> </div> <style> .header { width:400px; height:36px; line-height:36px; border:1px solid green; text-align:center; } .line { display:inline-block; width:100px; border-top:1px solid #cccccc; vertical-align:5px; // I saw online that .text is set to vertical-align:-5px. I tried it and it seems to conflict with the line-height set for .header, so the effect is not quite right. So set vertical-align to .line} </style> 2. CSS pseudo-class implementation effect: <div class="header"> <div>Text in the middle, horizontal lines on both sides</div> </div> <style> .header { width:400px; height:36px; line-height: 36px; text-align:center; border:1px solid green; position:relative; } .header div:before, .header div:after { position:absolute; background:#ccc; content:""; height:1px; top:50%; width:100px; } .header div:before{left:10px;} .header div:after{right:10px;} </style> Summarize The above is the CSS that I introduced to you to achieve the horizontal line effect on both sides of the middle text. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! |
<<: Vue template configuration and webstorm code format specification settings
>>: Detailed tutorial on installing pxc cluster with docker
This article describes how to install mysql5.7.16...
Python connects to MySQL to modify and query data...
This article example shares the specific code of ...
Simple function: Click the plug-in icon in the up...
1. Background We do some internal training from t...
<br />Although there are many web page creat...
Solution to MySQLSyntaxErrorException when connec...
MySQL official website: https://www.mysql.com/dow...
WEB development mainly consists of two interactio...
Use native JavaScript to simply implement the cou...
Problem Description html <iframe id="h5Co...
Table of contents 1.1. Network access between con...
Docker provides a way to automatically deploy sof...
Table of contents 1. What is a closure? 1.2 Memoi...
background As the business develops, the company&...