使用 CSS 值继承 `margin` 属性的作用
值为 `inherit` 的 `margin` 属性用于使元素继承父元素。你可以尝试运行以下代码来实现 `margin: inherit;`
示例
<!DOCTYPE html>
<html>
<head>
<style>
div {
border: 2px solid blue;
margin-left: 50px;
}
p.ex1 {
margin-left: inherit;
}
</style>
</head>
<body>
<p>Inheriting left margin from the parent element</p>
<div>
<p class = "ex1">This is demo text with inherited left margin.</p>
</div>
</body>
</html>输出

广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP