当前位置:网站首页>Differences between initial, inherit, unset, revert and all
Differences between initial, inherit, unset, revert and all
2022-07-03 12:42:00 【Elder martial brother Bai Ze】
initial
Represents the initial default value of the element attribute ( The default value is determined by the official CSS Specification definition )
Example
<p>
<span>This text is red.</span>
<em>This text is in the initial color (typically black).</em>
<span>This is red again.</span>
</p>
p {
color: red;
}
em {
color: initial;
}
inherit
Represents the calculated value of the attribute corresponding to the direct parent element of the element ,inherit Keywords only enhance the default behavior of attributes , Usually, it is only used when overwriting the original value . Inheritance always comes from the parent element in the document tree , Even if the parent element does not contain a block .
/* Set the color of the secondary title to green */
h2 {
color: green; }
/* ...but leave those in the sidebar alone so they use their parent's color */
#sidebar h2 {
color: inherit; }
unset
unset be relative to initial and inherit for , It's a little more complicated . Indicates that if this attribute is inheritable by default , Then the value is inherit; Otherwise, it's worth initial. actually , Set up unset Equivalent to not setting
<p>This text is red.</p>
<div class="foo">
<p>This text is also red.</p>
</div>
<div class="bar">
<p>This text is green (default inherited value).</p>
</div>
.foo {
color: blue;
}
.bar {
color: green;
}
p {
color: red;
}
.bar p {
color: unset;
}
revert
Represents the default value of the element attribute defined in the style sheet . If the user defines the explicit setting in the style sheet , Then press this setting ; otherwise , Define the style settings in the style sheet according to the browser ; otherwise , Equivalent to unset
<h3 style="font-weight: revert; color: revert;">
This should have its original font-weight (bold) and color: black
</h3>
<p>Just some text</p>
<h3 style="font-weight: unset; color: unset;">
This will still have font-weight: normal, but color: black
</h3>
<p>Just some text</p>
h3 {
font-weight: normal;
color: blue;
}
all
Indicates reset Division unicode-bidi and direction All but CSS Property value of property , The value can only be initial、inherit、unset and revert
<style> .test{
border: 1px solid black; padding: 20px; color: red; } .in{
/* all: initial; all: inherit; all: unset; all: revert; */ } </style>
<div class="test">
<div class="in"> Test text </div>
</div>
边栏推荐
- error: expected reference but got (raw string)
- 剑指Offer07. 重建二叉树
- Redhat5 installing socket5 proxy server
- 启用MemCached的SASL认证
- 232. Implement queue with stack
- Write a simple nodejs script
- 写一个简单的nodejs脚本
- Public and private account sending prompt information (user microservice -- message microservice)
- 2.9 overview of databinding knowledge points
- Exploration of sqoop1.4.4 native incremental import feature
猜你喜欢
With pictures and texts, summarize the basic review of C language in detail, so that all kinds of knowledge points are clear at a glance?
剑指Offer10- I. 斐波那契数列
Sword finger offer03 Repeated numbers in the array [simple]
剑指Offer05. 替换空格
公纵号发送提示信息(用户微服务--消息微服务)
TOGAF认证自学宝典V2.0
LeetCode 0556. Next bigger element III - end of step 4
最新版抽奖盲盒运营版
idea将web项目打包成war包并部署到服务器上运行
Use Tencent cloud IOT platform to connect custom esp8266 IOT devices (realized by Tencent continuous control switch)
随机推荐
Introduction to concurrent programming (II)
十條職場規則
Sword finger offer06 Print linked list from end to end
LeetCode 0556.下一个更大元素 III - 4步讲完
雲計算未來 — 雲原生
十条职场规则
Lambda expression
adb push apk
GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈
Swift5.7 扩展 some 到泛型参数
Redhat5 installing socket5 proxy server
Eureka self protection
实现验证码验证
Swift5.7 extend some to generic parameters
How to convert a decimal number to binary in swift
Summary of error prone knowledge points: Calculation of define s (x) 3*x*x+1.
LeetCode 0556. Next bigger element III - end of step 4
Swift return type is a function of function
剑指Offer03. 数组中重复的数字【简单】
Fundamentals of concurrent programming (III)