margin: 0 .2em 0 0什么意思
时间: 2023-03-21 09:02:22 浏览: 55
"margin: 0.2em 0 0" 是一个CSS样式表中的属性,它用于设置元素的边距。其中0.2em表示上下边距为0.2个字体大小的空白,而0表示左右边距为0。因此,这个样式将元素的上边距设置为0.2em,而左右和下边距都为0。
相关问题
解释一下{ margin: "3em 0em 0em", padding: "3em 0em" }
这是一个CSS样式,其中包含两个属性:margin和padding。它们分别用于设置元素的外边距和内边距。具体解释如下:
- margin: "3em 0em 0em" 表示元素的外边距分别为上方3em、左右方0em、下方0em。
- padding: "3em 0em" 表示元素的内边距分别为上下方3em、左右方0em。
*{ margin: 0; padding: 0; text-decoration: none; list-style: none; color: black; border: none; outline: none; } .topArea{ width: inherit; height: 500px; background-color: #414fe4; } .topArea>ul{ background-color: rgb(82, 82, 82); width: 100%; height: 50px; } .topArea>ul>li{ float: left; color: white; height: 50px; width: 100px; text-align: center; line-height: 50px; border-radius: 10px; cursor: pointer; margin: 0px 10px; } .topArea>ul>li:hover{ background-color: rgb(52, 52, 52); } .drop1:hover .dropDown1,.drop2:hover .dropDown2,.drop3:hover .dropDown3{ display: block; } .dropDown1,.dropDown2,.dropDown3{ background-color: azure; display: none; position: relative; /* width: 100px; height: 100px; */ z-index: 1; border-radius: 10px; } .dropDown1 li,.dropDown2 li,.dropDown3 li{ border-radius: 10px; } .dropDown1 li:hover,.dropDown2 li:hover,.dropDown3 li:hover{ background-color: #b5b5b5; } .menu1:hover .getMenu1,.menu8:hover .getMenu8{ display: block; } .getMenu1,.getMenu8{ display: none; position: absolute; left: 100%; background-color: white; border-radius: 10px; } /* [class^="getMenu"] { top: calc((attr(class, numeric)-1) * 50px); } */ [class^="getMenu"] { --menu-index: calc(1em * (parseInt(attr(class, 'numeric')) - 1)); top: var(--menu-index); } .getMenu1 li,.getMenu8 li{ float: none; width: 100px; height: 50px; }这段css代码中[class^="getMenu"] { --menu-index: calc(1em * (parseInt(attr(class, 'numeric')) - 1)); top: var(--menu-index); }没有生效怎么办
如果这段CSS代码没有生效,可能有以下几个原因:
1. 浏览器不支持CSS变量和属性选择器
如果您使用的是比较老的浏览器版本,可能会导致CSS变量和属性选择器无法生效。可以尝试升级浏览器版本,或者使用其他的CSS技术来实现类似的效果。
2. 类选择器没有匹配到对应的元素
如果您的HTML代码中没有任何一个class属性以"getMenu"开头的元素,那么这个类选择器就不会匹配到任何元素,从而导致样式没有生效。可以检查一下HTML代码,看看是否有符合条件的元素。
3. 代码中出现了其他错误
如果以上两个原因都排除了,那么可能是代码中出现了其他语法错误,导致整个规则失效。可以仔细检查一下代码,看看是否有拼写错误、语法错误等等。
另外,您可以使用浏览器的开发者工具来检查这段CSS代码是否被正确应用到了相应的元素上。如果没有被应用,那么开发者工具会显示相应的错误信息,帮助您找到问题所在。