CSS中的inherit关键字是什么? [英] What does the inherit keyword in CSS do?

查看:169
本文介绍了CSS中的inherit关键字是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以解释一下,继承关键字在CSS中是什么意思?

Can somebody please explain, what is the inherit keyword meant to do in CSS?

推荐答案

作为他的父母拥有相同的财产。

It will use the same value as the same property his parent has.

html:

<body>
<h1></h1>
</body>

css:

body{
 margin: 234px;
}
h1{
 margin: inherit; #=234px
}

请注意,如果有多个实例< h1> 在文件中,它将占用其父级的边距。所以234px并不总是它的值。例如

Note to this if there are multiple instances of <h1> in the file, it will take the margin of it's parent. So 234px is not always the value it will have. For example

html:

<body>
  <h2></h2>
  <div>
    <h2></h2>
  </div>
</body>

css:

body{
margin: 20px;
}
div{
margin: 30px;
}
h2{
margin: inherit; #20px if parent is body; 30px if parent is div
}

这篇关于CSS中的inherit关键字是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆