This article summarizes various ways to implement article dividing lines in CSS. Dividing lines can beautify the page, so let's take a look at various ways to use CSS to implement dividing line styles. The effect is as follows: Method 1: Use a single label to implement a separator line:html: <div class="line_01">Single label implementation of small separator line</div> css: .demo_line_01{ padding: 0 20px 0; margin: 20px 0; line-height: 1px; border-left: 190px solid #ddd; border-right: 190px solid #ddd; text-align: center; } Advantages: concise code Method 2: Use background color to create separator lines:html: <div class="line_02"><span>Small dividing line cleverly implemented with color</span></div> css: .demo_line_02{ height: 1px; border-top: 1px solid #ddd; text-align: center; } .demo_line_02 span{ position: relative; top: -8px; background: #fff; padding: 0 20px; } Advantages: concise code, adaptive width Method 3: inline-block to implement separator line:html: <div class="line_03"><b></b><span>Small separator line inline-block implementation</span><b></b></div> css: .demo_line_03{ width:600px; } .demo_line_03 b{ background: #ddd; margin-top: 4px; display: inline-block; width: 180px; height: 1px; _overflow:hidden; vertical-align: middle; } .demo_line_03 span{ display: inline-block; width: 220px; vertical-align: middle; } Method 4: Floating to achieve separator line:html: <div class="line_04"><b></b><span>The small separator line floats to achieve</span><b></b></div> css: .demo_line_04{ width:600px; } .demo_line_04{ overflow: hidden; _zoom: 1; } .demo_line_04 b{ background: #ddd; margin-top: 8px; float: left; width: 26%; height: 1px; _overflow:hidden; } Method 5: Use characters to implement separators:html: <div class="line_05">———————————<span>Small separator character to achieve</span>————————————</div> css: .demo_line_05{ letter-spacing: -1px; color: #ddd; } .demo_line_05 span{ letter-spacing: 0; color: #222; margin:0 20px; } Advantages: The code is concise. The above briefly introduces how to write separators. There may be other more appropriate ways to write them, depending on the environment! This concludes this article about the various methods of implementing article dividing line styles with CSS. For more relevant CSS dividing line style content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope that everyone will support 123WORDPRESS.COM in the future! |
<<: Detailed steps to install RabbitMQ in docker
>>: Angular Cookie read and write operation code
background Solving browser compatibility issues i...
MySQL is the most popular relational database man...
Mongodb has a db.serverStatus() command, which ca...
AWS - Amazon's cloud computing service platfo...
1. Element time selection submission format conve...
Rendering Define the skeleton, write HTML and CSS...
If someone asked you whether running EXPLAIN on a...
As a programmer who has just learned Tomcat, this...
Table of contents vue custom directive Global Dir...
1. Install MySQL database on mac 1. Download MySQ...
Table of contents Overview Subqueries Subquery Cl...
Recently, a friend asked me a question: When layo...
Recently, WeChat Mini Program has proposed adjust...
MySQL versions are divided into Enterprise Editio...
Preface For security reasons, the root user of My...