Summary of various methods of implementing article dividing line styles with CSS

Summary of various methods of implementing article dividing line styles with CSS

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

Recommend

A brief discussion of several browser compatibility issues encountered

background Solving browser compatibility issues i...

MySQL 5.7.24 installation and configuration method graphic tutorial

MySQL is the most popular relational database man...

Zabbix3.4 method to monitor mongodb database status

Mongodb has a db.serverStatus() command, which ca...

Teach you how to use AWS server resources for free

AWS - Amazon's cloud computing service platfo...

Sharing tips on using vue element and nuxt

1. Element time selection submission format conve...

Vue realizes the whole process of slider drag verification function

Rendering Define the skeleton, write HTML and CSS...

Why the explain command may modify MySQL data

If someone asked you whether running EXPLAIN on a...

Detailed explanation of filters and directives in Vue

Table of contents vue custom directive Global Dir...

How to modify the forgotten password when installing MySQL on Mac

1. Install MySQL database on mac 1. Download MySQ...

MySQL subqueries and grouped queries

Table of contents Overview Subqueries Subquery Cl...

Specific use of the wx.getUserProfile interface in the applet

Recently, WeChat Mini Program has proposed adjust...

Detailed tutorial on downloading mysql on Windows 10

MySQL versions are divided into Enterprise Editio...

Basic steps to use Mysql SSH tunnel connection

Preface For security reasons, the root user of My...