About the overlap of margin value and vertical margin in CSS

About the overlap of margin value and vertical margin in CSS

Margin of parallel boxes (overlap of double margins) interview question: If one box has a top margin and the other box has a bottom margin, will there be a margin overlap problem? Solution: Take the larger value, not the sum of their values, but the one with the larger value will prevail!

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title></title>
    <style type="text/css">
    *{margin: 0;padding: 0;}
    .box1,.box2{
    width: 200px;
    height: 200px;    
    }
    .box1{
    background-color: #f90;
    margin-bottom: 20px;
    }
    .box2{
    background-color: aqua;
    margin-top: 50px;
    }
    </style>
</head>
<body>
    <div class="box1"></div>
    <div class="box2"></div>
</body>
</html> 

Margin and padding have the same orientation and value, in clockwise direction (up, right, bottom, left). Click to view "Padding and abbreviations for CSS box model"

This is the end of this article about margin values ​​and vertical margin overlap in CSS. For more information about margin and vertical margin overlap, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

<<:  HTML cellpadding and cellspacing attributes explained in pictures

>>:  How to connect to a remote docker server with a certificate

Recommend

How to dynamically add ports to Docker without rebuilding the image

Sometimes you may need to modify or add exposed p...

Web Design Experience

<br />The author used to be a novice in web ...

Tutorial on building an FTP server in Ubuntu 16.04

Ubuntu 16.04 builds FTP server Install ftp Instal...

How to use Zen coding in Dreamweaver

After I published my last article “Zen Coding: A Q...

MySQL Installer Community 5.7.16 installation detailed tutorial

This article records the detailed tutorial of MyS...

How to implement DIV's blur function

Use anti-shake to make DIV disappear when the mou...

Summary of Form Design Techniques in Web Design

“Inputs should be divided into logical groups so ...

Enterprise-level installation tutorial using LAMP source code

Table of contents LAMP architecture 1.Lamp Introd...

Solution to the problem of slow docker pull image speed

Currently, Docker has an official mirror for Chin...

Design Theory: Text Legibility and Readability

<br />Not long ago, due to business needs, I...

Summary of MySQL InnoDB locks

Table of contents 1. Shared and Exclusive Locks 2...

How to periodically clean up images that are None through Jenkins

Preface In the process of continuous code deliver...

mysql error number 1129 solution

SQLyog connects to mysql error number 1129: mysql...

JavaScript implements the protocol example in which the user must check the box

In js, set the user to read a certain agreement b...