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

New settings for text and fonts in CSS3

Text Shadow text-shadow: horizontal offset vertic...

CnBlogs custom blog style sharing

After spending half the night on it, I finally ma...

Nginx uses ctx to realize data sharing and context modification functions

Environment: init_worker_by_lua, set_by_lua, rewr...

React Native scaffolding basic usage detailed explanation

Build the project Execute the command line in the...

Summary of Mathematical Symbols in Unicode

There are many special symbols used in mathematic...

Detailed explanation of how to view the current number of MySQL connections

1. View the detailed information of all current c...

Detailed tutorial on deploying Django project using Docker on centos8

introduction In this article, we will introduce h...

Complete Tutorial on Deploying Java Web Project on Linux Server

Most of this article refers to other tutorials on...

The use and methods of async and await in JavaScript

async function and await keyword in JS function h...

vue3.0+echarts realizes three-dimensional column chart

Preface: Vue3.0 implements echarts three-dimensio...

Use js to call js functions in iframe pages

Recently, I have been working on thesis proposals ...

isPrototypeOf Function in JavaScript

Table of contents 1. isPrototypeOf() Example 1, O...

Detailed explanation of the background-position percentage principle

When I was helping someone adjust the code today,...

MySQL 8.0.25 installation and configuration method graphic tutorial

The latest download and installation tutorial of ...