gpt4 book ai didi

css - 如何在顶部框架上添加一个小图像和一个图像容器,同时控制容器的背景颜色

转载 作者:行者123 更新时间:2023-11-28 08:10:40 24 4
gpt4 key购买 nike

我有一个 html 页面,它通过 css 而不是通过 html frameset 标签由顶部、左侧和右侧框架分隔。我想将一个小图像添加到顶部框架,但能够控制顶部框架的背景颜色。我遇到的问题是我看到添加了图像,但没有指定背景颜色。

CSS文件

#foo {
background-color : blue;
background-image : url("foo.png");
width : 100px;
height : 50px;
}

html文件

<html>
...<body>
<div id="foo"></div>
...</body></html>

[用答案更新]

在阅读了 Marcelo 和 Paulie_D 对这个问题的回复后,我意识到我必须做的事情(首先更正我的问题并在此处添加答案)。

<html>
...<body>
<div id="container">
<div id="foo"></div>
</div>


#container {
background-color : blue;
}

#foo {
background-image : url('foo.png');
width : 100px;
height : 50px;
}

最佳答案

绝对提供图像具有透明度..

div {
width: 200px;
height: 200px;
background-image: url(http://www.clker.com/cliparts/1/c/c/f/13902170611226395134cat_png_by_dbszabo1-d3dn2c8.png);
background-size: cover;
background-color: lightblue;
}
<div>
<h1>My Cat</h1>
</div>

关于css - 如何在顶部框架上添加一个小图像和一个图像容器,同时控制容器的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29287683/

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