Html 背景div不显示 身体{ 背景色:#444669; } #1 { 背景色:#DD2124; 高度:337px; 宽度:388px; }
我试图用不同的背景色制作div的一部分,但它根本不显示。CSS中的Id不能以数字开头。只需将Html 背景div不显示 身体{ 背景色:#444669; } #1 { 背景色:#DD2124; 高度:337px; 宽度:388px; },html,background,Html,Background,我试图用不同的背景色制作div的一部分,但它根本不显示。CSS中的Id不能以数字开头。只需将#1更改为例如#first即可 预览: 身体{ 背景色:#444669; } #首先{ 背景色:#DD2124; 高度:337px; 宽度:388px; } 更新: 您可以使用以下技巧将id实际保留为一个数字: <!doctype html> <html> <style type="text/css"> body { background-color: #
#1
更改为例如#first
即可
预览:
身体{
背景色:#444669;
}
#首先{
背景色:#DD2124;
高度:337px;
宽度:388px;
}
更新:
您可以使用以下技巧将id实际保留为一个数字:
<!doctype html>
<html>
<style type="text/css">
body {
background-color: #444669;
}
#first {
background-color: #DD2124;
height: 337px;
width: 388px;
}
</style>
<body>
<div id="first"></div>
</body>
</html>
身体{
背景色:#444669;
}
[id='1']{
背景色:#DD2124;
高度:337px;
宽度:388px;
}
<!doctype html>
<html>
<style type="text/css">
body {
background-color: #444669;
}
#first {
background-color: #DD2124;
height: 337px;
width: 388px;
}
</style>
<body>
<div id="first"></div>
</body>
</html>
<style type="text/css">
body {
background-color: #444669;
}
[id='1'] {
background-color: #DD2124;
height: 337px;
width: 388px;
}
</style>