<style>
css的继承性
/* 哪些属性能继承? */
/* color、 text-开头的、line-开头的、font-开头的 */
.con{
color: aquamarine;
font-size: 30px;
font-weight: bolder;
/* italic 字体斜体 */
font-style: italic;
text-align: center;
/* 下划线 */
text-decoration: underline;
/* 行高 */
line-height: 50px;
}
</style>
</head>
<body>
<!-- 有一些属性,当给自己设置的时候,自己的后代都继承上了,这个就是继承性 -->
<!--继承性是从自己开始,直到最小的元素-->
- <div class="con">
- <!-- 这个“你好”文本,是里面内容 -->
- 你好
- <!-- 这个“段落”文本,是我的后代p里面的内容 -->
- <div class="con">
- <p>段落</p>
- <p>段落</p>
- <p>段落</p>
- </div>
- <div>
- <p>段落</p>
- <p>段落</p>
- </div>
- <div>
- <span>小芮</span>
- <a href="">百度</a>
- <em>爱奇艺</em>
- </div>
- </div>
- </body>
效果图:

关于盒子的、定位的、布局的属性都不能继承
- <!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>Document</title>
- <style>
- /* 关于盒子的、定位的、布局的属性都不能继承 */
- .con{
- width: 30px;
- height: 300px;
- border: 3px solid skyblue;
-
-
- outline: 2px dashed yellow;
- }
- </style>
- </head>
- <body>
- <div class="con">
- <p>断落</p>
- <p>断落</p>
- <p>断落</p>
- </div>
- </body>
- </html>