<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> .ysa{background-color: red; width:600px; height: 20px; } .ysb{background-color: green; width:600px; height: 20px; } .ysc{background-color: blue; width:600px; height: 20px; } </style> </head> <body> <div style="background-color: red;width:600px;height: 20px;">草</div> <div style="background-color: green;width:600px;height: 20px;">(唐)白居易></div> <div style="background-color: blue;width:600px;height: 20px;">离离原上草,一岁一枯荣。</div> <div class=".ysa">野火烧不尽,春风吹又生。</div> </body> </html> 这个代码哪里有错
时间: 2024-02-20 16:01:03 浏览: 81
这个代码有两处错误:
1. 在第13行,div的class名应该是"ysa",而不是".ysa"。正确代码是:
```
<div class="ysa">野火烧不尽,春风吹又生。</div>
```
2. 在第5行,meta标签的content属性应该是"width=device-width, initial-scale=1.0",而不是"width=device-width, initial-scale=1"。正确代码是:
```
<meta name="viewport" content="width=device-width, initial-scale=1.0">
```
修改后的代码如下:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.ysa{
background-color: red;
width:600px;
height: 20px;
}
.ysb{
background-color: green;
width:600px;
height: 20px;
}
.ysc{
background-color: blue;
width:600px;
height: 20px;
}
</style>
</head>
<body>
<div style="background-color: red;width:600px;height: 20px;">草</div>
<div style="background-color: green;width:600px;height: 20px;">(唐)白居易></div>
<div style="background-color: blue;width:600px;height: 20px;">离离原上草,一岁一枯荣。</div>
<div class="ysa">野火烧不尽,春风吹又生。</div>
</body>
</html>
```
阅读全文