1. a标签的颜色
a标签的颜色是不会从父元素继承过来,如果要设置a标签的颜色,必须要直接指定。
如下: 必须直接指定a标签的颜色。
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.father{
color:red;
}
a{
color:pink; /* 必须要要直接指定a标签的颜色*/
}
</style>
</head>
<body>
<div class="father">
<a href="#">a标签这段文字的颜色</a>
</div>
</body>
</html>
2. h标签字体的大小
h标签的字体的大小不会从父元素继承过来,如果要设置指定就行了。
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.father{
color:red;
font-size: 20px;
}
</style>
</head>
<body>
<div class="father">
<h1>标题</h1>
</div>
</body>
</html>
3. div的宽高
如果div不设置宽高,那么这个div的宽从父元素直接继承,高度为0
div的宽是可以继承的,高是不可以继承的。
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.father{
width:500px;
height: 500px;
background-color: red;
}
.son{
}
</style>
</head>
<body>
<div class="father">
<div class="son">
</div>
</div>
</body>
</html>