Summary of experience in using div box model

Summary of experience in using div box model
Calculation of the box model <br />Margin + border + padding + content

The width and height in CSS only set the height and width of the content area. Not the height and width of the entire model.

Copy code
The code is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>demo</title>
<style type="text/css">
*{margin:0; padding:0;}
dl { background:red;border:10px solid #000; width:100px; height:100px;}
dt { background:yellow;}
dd { background:green;}
</style>
</head>
<body>
<dl>
<dt>test of dt</dt>
<dd>test of dd</dd>
</dl>
</body>
</html>

Setting margins and padding will not affect the height and width of the content area, but only change the height and width of the secondary box model area.

When the box models are nested, the inner box model will affect the outer box model.

<<:  The actual process of implementing the guessing number game in WeChat applet

>>:  The difference between animation and transition

Recommend

How to create LVM for XFS file system in Ubuntu

Preface lvm (Logical Volume Manager) logical volu...

Five ways to implement inheritance in js

Borrowing Constructors The basic idea of ​​this t...

mysql 5.7.23 winx64 decompression version installation tutorial

Detailed installation tutorial of mysql-5.7.23-wi...

How to implement h5 input box prompt + normal text box prompt

XML/HTML CodeCopy content to clipboard < input...

The whole process of installing and configuring Harbor1.7 on CentOS7.5

1. Download the required packages wget -P /usr/lo...

Detailed steps to install web server using Apache httpd2.4.37 on centos8

Step 1: yum install httpd -y #Install httpd servi...

How to configure tomcat server for eclipse and IDEA

tomcat server configuration When everyone is lear...

What are the rules for context in JavaScript functions?

Table of contents 1. Rule 1: Object.Method() 1.1 ...

How to create a swap partition file in Linux

Introduction to Swap Swap (i.e. swap partition) i...

How to use pdf.js to preview pdf files in Vue

When we preview PDF on the page, some files canno...

Summary of MySQL date and time functions (MySQL 5.X)

1. MySQL gets the current date and time function ...

Details on using regular expressions in MySQL

Table of contents 1. Introduction 2. Prepare a pr...

Detailed explanation of Tomcat's commonly used filters

Table of contents 1. Cross-domain filter CorsFilt...