如何在HTML中将多个透明图像设置为背景?
以下是当前的背景:如何在HTML中将多个透明图像设置为背景?,html,css,Html,Css,以下是当前的背景: <html> <head> <title></title> </head> <body style="background: #5d5d5d url(images/tile_dark.png); border: 20px solid #00c09e; margin: 0;
<html>
<head>
<title></title>
</head>
<body style="background: #5d5d5d url(images/tile_dark.png);
border: 20px solid #00c09e;
margin: 0;
padding: 0;">
</body>
</html>
我需要在绿色边框上显示另一个图像。我怎么做?更新:添加
您可以创建一个
,如:
<div id="another"></div>
不能在元素外部显示元素的背景。你可以试着做一个测试
body::after{
content:'';
display:block;
position:absolute;
width:100%;
height:100%;
background:url(images/yourimage)
};
对于同一元素上的多个图像,请使用逗号分隔它们,如:
background: #color1 background:url(path-to-image1) 0px 0px no-repeat, #color2 background:url(path-to-image) 1px 1px repeat-x; /*and so on*/
也不能使背景图像透明,只能使背景颜色透明。如果需要背景图像透明,请更改元素的不透明度。对于透明背景色用户:
background:rgba(255,255,255,0.5); /*first 3 are color codes -RGB, last one is opacity from 0 to 1*/
在边框图像上设置背景, 试试CSS 编辑:
是否应仅在绿色边框上显示另一图像?是。现在的边框只是一种颜色。我需要它作为一个颜色和图像。谢谢拉杜,但我期待着显示一个已经透明的图像上只有绿色的边界。那么你可以有一个小提琴的例子吗?这将帮助我帮助你们,因为我怀疑你们有一个元素,有一个图像作为背景添加,包装在一个边界和背景溢出的边界。我认为html框架可能与您的示例不同。
background:rgba(255,255,255,0.5); /*first 3 are color codes -RGB, last one is opacity from 0 to 1*/
body {
background: green;
}
#another{
background: blue;
width: 50%;
border-image: url(http://cdn.wonderfulengineering.com/wp-content/uploads/2014/04/space-wallpaper-2-798x350.jpg) 30 30 round;
border-width: 10px;
margin: auto;
height: 200px;
}