css中,怎样让一个class继承另一个class的属性?

html-css023

css中,怎样让一个class继承另一个class的属性?,第1张

1、新建一个html文件,命名为test.html。

2、在test.html文件内,使用table标签创建一个表格,并使用border设置表格边框为1px。

3、在test.html文件内,在table标签内,使用tr、td标签设置为两行两列表格。

4、在css标签内,设置类名为t1的样式,使用width属性设置宽度为250px,使用height属性设置高度为200px。

5、在css标签内,设置类名为t2的样式,使用font-size属性设置文字大小为20px,使用color属性设置文字颜色为红色,使用text-align属性设置文字居中。

6、在test.html文件内,在table标签内添加class属性,把class属性值设置为“t1 t2”,从而实现给表格添加两个class样式。

一、不能继承的属性

① 盒子模型所有属性:margin、padding、border、width、height。

② 轮廓及背景属性:outline、background。

③ 定位、显示、浮动属性:display、position、top、left、right、bottom、max-*(如max-height等)、overflow、clear、float、content、z-index。

④ 其他:vertical-align、text-decoration、text-shadow、white-space。

注意:内联元素不能继承:text-indent和text-align,但是块级元素可以。

二、元素可继承属性

① 所有元素可继承:visibility、cursor。

② 列表元素可继承:list-style、list-style-type、list-style-position、list-style-image。

③ 字体属性:line-height、color、font、font-family、font-size、font-style、font-variant、font-weight、font-size-adjust。

④ 文本属性:text-transform、direction,除了(text-decoration、text-shadow 内联元素不能继承 ) 块级 可继承。

⑤ 表格布局属性:caption-side、border-collapse、border-spacing、empty-cells、table-layout。

⑥ 其它属性:letter-spacing、word-spacing。

如果还有您知道的,希望可以留言补充。

如果喜欢,不要吝啬你的爱心“❤”哦!