Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
这一小块html/css没有';不行?_Html_Css - Fatal编程技术网

这一小块html/css没有';不行?

这一小块html/css没有';不行?,html,css,Html,Css,这个代码不起作用,我不明白为什么 <!DOCTYPE html> <html> <head> <style type="text/css"> .class1{ float:left; margin:10px; background:#09C; width:100px; height:100px; cursor:pointer;} .class2{ float:left; margin:10px; background:#0C0; width:100

这个代码不起作用,我不明白为什么

<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.class1{ float:left; margin:10px; background:#09C; width:100px; height:100px; cursor:pointer;}
.class2{ float:left; margin:10px; background:#0C0; width:100px; height:100px; cursor:pointer; }
</style>

</head>
<body>
<div class="class 1" onclick="toggleClass(this)"></div>
<div class="class 1" onclick="toggleClass(this)"></div>
<div class="class 1" onclick="toggleClass(this)"></div>
<div class="class 1" onclick="toggleClass(this)"></div>
</body>
</html>

.class1{浮点:左;边距:10px;背景:#09C;宽度:100px;高度:100px;光标:指针;}
.class2{浮点:左;边距:10px;背景:#0C0;宽度:100px;高度:100px;光标:指针;}

您不能在类名中使用空格,
请在您的问题中将代码片段作为文本传递(不需要图像),这样我们就可以复制/传递并测试,还可以包含javascript并告诉我们什么不起作用定义“不起作用”。它可能工作得很完美,只是不是你想要的方式。啊,就是这么简单。。谢谢,我完全错过了。欢迎,为什么我被否决了?:)class标记中的空格是有效的html,因为您可以添加多个类。在这种情况下,有两个类,一个称为
class
,另一个称为
1
。虽然说
1
类是无效的,因为类必须以下划线(u)、连字符(-)或字母(a–z)开头。没错,我只是不清楚,我想说类名不能与内部空格一起使用:),所以可以使用“class_1”而不是“class 1”作为类名。