gpt4 book ai didi

html - 无法设置div的背景颜色

转载 作者:太空宇宙 更新时间:2023-11-04 02:07:53 24 4
gpt4 key购买 nike

我有这个代码:

<html>
<head>
<title>Document Title</title>
</head>
<body>
<div style="border:1px solid black;"
style="background-color: green !important;">
Test Text
</div>
</body>
</html>

边框按规定存在。但是,div 的背景不是绿色的。为什么div的背景不是绿色的?

我知道这是基本的,但我已经阅读了几个小时,但我无法在任何地方找到答案。

最佳答案

使用一个样式属性。此外,您不需要 !important,内联样式始终具有最高优先级。

<div style="border:1px solid black; background-color: green;">
Test Text
</div>

关于html - 无法设置div的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40364152/

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