gpt4 book ai didi

css - 无法更改特定 div 的背景颜色

转载 作者:行者123 更新时间:2023-11-28 04:09:16 25 4
gpt4 key购买 nike

我是 CSS 的新手,我正在尝试构建一个非常简单的网站,我已经完成了大部分布局,现在的问题是,当我为 divs B+c、B 和 C 输入特定的背景颜色属性时,它会出现'似乎没有任何效果,我检查了其他问题,我知道我应该使用 overflow:hidden;也试过 clear:both;但它们似乎都不起作用,你能指出我做错了什么吗?

<!doctype html>
<html>
<style>
body {
background: url(5750520604_febd0975e8_o.jpg), linear-gradient(180deg, #FFFFFF 80%, #B4B4B4 20%);
background-color: white;
background-size: 70%;
background-attachment: fixed;
background-repeat: no-repeat;
}

#A {
overflow: hidden;
border: none;
}

object {
width: 1500px;
height: 800px;
display: inline-block;
}

#B {
background-color: #777676;
clear: both;
display: flex;
overflow: hidden;
margin-left: -10px;
border: none;
width: 600px;
border: thick;
height: 300px;
display: inline-block;
margin-right: 0px;
float: left;
}

#C {
background-color: #777676;
clear: both;
display: flex;
flex: 0 1 auto;
overflow: hidden;
border: thick;
width: 1250px;
height: 300px;
display: inline-block;
margin-right: -10px;
}

#B+C {
background-color: #777676;
clear: both;
overflow: hidden;
border: none;
width: 1900px;
height: 1000px;
}

.webmaster {
background-color: #777676;
clear: both;
margin-left: -10px;
background-color: white;
overflow: hidden;
height: 80px;
width: 1920px;
border: none;
font-family: Georgia;
text-align: justify;
padding: 20px 640px;
font-size: 20px;
margin-top: -5px;
}

a:link {
text-decoration: none;
color: #000000;
}

a:visited {
text-decoration: none;
color: #4C4C4C;
}

a:hover {
text-decoration: none;
color: #B2B2B2;
}

a:active {
color: #000000;
text-decoration: underline;
}
</style>

<head>
<meta charset="utf-8">
<title>Rodriguez Tullio Propiedades</title>
</head>

<body>

<div id="A">
<object type="text/html" data="A.html">
</object></div>
<div id="B+C">
</div>
<div id="B">
<object type="text/html" data="B.html">
</object></div>
<div id="C">
<object type="text/html" data="C.html">
</object></div>

<div class="webmaster">2017 | <a href="mailto:webmaster@tullio.com.ar">webmaster@tullio.com.ar</a> |</div>


</body>

</html>

最佳答案

这里有两个问题:

  1. 您不能使用B+C 作为您的id 属性。根据文档:

The value must not contain any space characters. HTML 4: ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

  1. B+C 使用特定的adjacent 运算符(+ 符号)。在 CSS 中,这意味着样式定义将以带有标记 C 的 DOM 元素为目标,该元素紧跟在带有标记 B 的 DOM 元素之后。

首先,在您的 HTML 标记中,尝试将 id="B+C" 更改为 id="D"。然后,在您的 CSS 中,将 #B+C 更改为 #D

工作示例:https://jsfiddle.net/gkh2pj2j/1/

关于css - 无法更改特定 div 的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42795426/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com