Html 如何从css中排除元素?
注: 我环顾了其他线程,但我似乎无法找到有效的答案 我一直试图从“body{}”中的margin属性中排除“#menu”,这样它就不会与文本重叠 我的代码:Html 如何从css中排除元素?,html,css,tags,Html,Css,Tags,注: 我环顾了其他线程,但我似乎无法找到有效的答案 我一直试图从“body{}”中的margin属性中排除“#menu”,这样它就不会与文本重叠 我的代码: body { text-align: center; background: black; background: url("http://tuxlink.files.wordpress.com/2010/04/snow-leopard-server-wallpaper.jpg"); font-family:
body {
text-align: center;
background: black;
background: url("http://tuxlink.files.wordpress.com/2010/04/snow-leopard-server-wallpaper.jpg");
font-family: Helvetica;
background-size: 100%;
background-position: center center;
background-repeat: no-repeat;
color: black;
background-attachment: fixed;
background-size: cover;
font-size: 20px;
margin: 15%;
}
#menu{
position: absolute;
color: white;
position: fixed;
background-attachment: fixed;
border: 5px;
background-color: grey;
background-size: contain;
border-style: ridge;
border-color: grey;
width: 150px;
text-align: left;
float: left;
}
使用菜单的CSS覆盖正文中的CSS:
#menu { border: none; border-width: 5px; }
添加您可能需要的任何内容。如果您试图将
#菜单上的边距重置为默认值,您可以添加边距:无代码>添加到CSS中,使其看起来像这样:
body {
text-align: center;
background: black;
background: url("http://tuxlink.files.wordpress.com/2010/04/snow-leopard-server-wallpaper.jpg");
font-family: Helvetica;
background-size: 100%;
background-position: center center;
background-repeat: no-repeat;
color: black;
background-attachment: fixed;
background-size: cover;
font-size: 20px;
margin: 15%;
}
#menu{
position: absolute;
color: white;
position: fixed;
background-attachment: fixed;
border: 5px;
background-color: grey;
background-size: contain;
border-style: ridge;
border-color: grey;
width: 150px;
text-align: left;
float: left;
margin: none;
}
那就应该成功了 可能是你菜单里的东西
#菜单{
位置:绝对;您尝试过在#菜单上设置边距吗?您至少应该提到您看过的“线程”(问题),并指定给出的答案不令人满意的原因。您肯定不能“从CSS中排除元素”(CSS没有元素,它只有匹配HTML或XML元素的选择器)和文本“从“body{}”中的margin属性中排除“#menu”,使其不与文本重叠”的描述不是问题。
#menu{
position:absolute; <-- this are interfering with your margins
color:white;
position:fixed; <-- this are interfering with your margins
float:left; <-- this are interfering with your margins
margin: none; <-- remove that and try set the margin here (eg: margin: 10px;)
}