A brief discussion on CSS blocking merging and other effects

A brief discussion on CSS blocking merging and other effects

Non-orthogonal margins

When margin is used, it will cause merging

The following properties will prevent margin merging:

border

display: table

display: flex

The above content is the result of the detailed explanation below

Blocking merger [Detailed explanation]

/* CSS */

    .box{
        border:1px solid red;
        height: 100px;
        margin: 10px; /* Note: this is 10 pixels! */
    }
<!-- HTML -->

<div class="box"></div>
<div class="box"></div>
<div class="box"></div>

This is what it looks like in the browser:

According to the rational number margin, the spacing between the top and bottom of the div should be 20px

Solution 1:

<!-- HTML -->
<!-- css unchanged -->

<div class="box"></div>
<div style="border: 1px solid blue"></div> <!-- Newly added -->
<div class="box"></div>
<div style="border: 0.1px solid blue"></div> <!-- Newly added -->
<div class="box"></div>
<div class="box"></div>

This is what it looks like in the browser:

<!-- HTML -->
<!-- css unchanged -->

<!-- HTML -->
<div class="box"></div>
<div style="display: table"></div>
<div class="box"></div>
<div style="display: flex"></div>
<div class="box"></div>
<div class="box"></div>
<!-- display:block / inline will not block merging, only table flex can -->

This is what it looks like in the browser:

Other Impacts

display will affect the small dots of ul li

position: absolute will affect display: inline

position: fixed will affect transform

float affects inline

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.

<<:  Detailed explanation of creating, calling and managing MySQL stored procedures

>>:  Usage of the target attribute of the html tag a

Recommend

MySQL replication advantages and principles explained in detail

Replication is to transfer the DDL and DML operat...

How to use Web front-end vector icons

Preface When writing front-end pages, we often us...

Implementation of select multiple data loading optimization in Element

Table of contents Scenario Code Implementation Su...

Understanding the Lazy Loading Attribute Pattern in JavaScript

Traditionally, developers create properties in Ja...

Example of cross-database query in MySQL

Preface In MySQL, cross-database queries are main...

Realize the CSS loading effect after clicking the button

Since there is a button in my company's produ...

Detailed steps for deploying Tomcat server based on IDEA

Table of contents Introduction Step 1 Step 2: Cre...

Three Discussions on Iframe Adaptive Height Code

When building a B/S system interface, you often en...

Summary of Linux ps and pstree command knowledge points

The ps command in Linux is the abbreviation of Pr...

Vue integrates Tencent Map to implement API (with DEMO)

Table of contents Writing Background Project Desc...

Analysis of the event loop mechanism of js

Preface As we all know, JavaScript is single-thre...

Detailed tutorial on installing JDK1.8 on Linux

1. Cleaning before installation rpm -qa | grep jd...

Docker builds kubectl image implementation steps

If the program service is deployed using k8s inte...