Home  >  Article  >  Web Front-end  >  在学HTML和css遇到的一个问题_html/css_WEB-ITnose

在学HTML和css遇到的一个问题_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:42:59926browse

 





css定义时
.user_wrap { width: 160px; padding-bottom: 30px; position: relative; }
.clear { zoom:1; }
请问为什么可以把那个类名分开来定义。
注:这个例子可以跑的,就是不知到它的原理为什么可以这样定义。


回复讨论(解决方案)

可以有多个class,后面的优先级更高

我知道!可以有多个class,但是针对这个问题,他只定义了一个类名“user_wrap  clear”而用的时候他却可以把类名拆开来用,是不是跟空格有关呢

恩。。。是的,,,多个类名,使用空格隔开,,比如 有  三个类名   .a  .b  .c    你使用的时候,直接class="a  b  c "  越在后,他的优先级越高。比如你使用a b c 定义了三个不同的颜色,,然后只显示c的颜色。。你可以试试

“user_wrap  clear”并非只定义了一个类名,而是两个

一个div可以同时享用很多个类, 而区别类就需要在后面加上空格。像3楼所说的那样。
因为类可以让很多div共用,所以

 这么写的话,可能是页面中其他的div需要用到.user_wrap 这个类,而clear只是这个div需要用到 才另外加上去的。

谢谢大家!

一个div可以同时享用很多个类, 而区别类就需要在后面加上空格。像3楼所说的那样。
因为类可以让很多div共用,所以

 这么写的话,可能是页面中其他的div需要用到.user_wrap 这个类,而clear只是这个div需要用到 才另外加上去的。
谢谢大家!我懂了
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn