1. Limpiar los márgenes interior y exterior
2. Código:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>清除内外边距</title>
<style>
*{
margin: 0;
padding: 0;
}
</style>
</head>
<body>
123
<ul>
<li>abcd</li>
</ul>
</body>
</html>
3. Efecto de la operación:
4. Los elementos en línea solo pueden establecer los márgenes interior y exterior izquierdo y derecho
5. Código
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>清除内外边距</title>
<style>
span{
background-color: pink;
margin: 20px;
}
</style>
</head>
<body>
<span>行内元素尽量只设置左右的内外边距</span>
</body>
</html>
resultado de ejecución:
Nota: debido a los diferentes navegadores, antes del diseño, primero debe borrar los márgenes interior y exterior de los elementos de la página web