背景CSS不显示在包装器后面

问题描述 投票:1回答:3

我已经在CSS中尝试了background-image标记,也在HTML中的标记中尝试过。我无法在封装器后面看到任何内容。我可以让我的包装背景显示颜色,但它。

html,
body {
    background-image: url("https://vgy.me/u/TpG24N");
    text-align: center;
    height: 100%;

}

#wrapper {
    margin: 2% auto;
    width: 875px;
    height: 80%;
    box-sizing: border-box;
    background-color: rgb(250, 194, 245)
}

#subwrapper {
    position: relative;
}
html css background-image wrapper
3个回答
1
投票

你的背景图片网址https://vgy.me/u/TpG24N不是指图像,你的意思是https://vgy.me/TpG24N.jpg

html,
body {
    background-image: url("https://vgy.me/TpG24N.jpg");
    text-align: center;
    height: 100%;

}

1
投票

你在#wrapper中设置了一个背景颜色,它不会显示任何东西。只需设置:

#wrapper{
 background-color: transparent;
}

现在#wrapper背后的元素将显示出来。

Edit`:

如果你愿意,你也可以制作semi-transparent,保持你的颜色并将opacity设置为0到1之间的值,如下所示:

#wrapper {
    background-color: rgb(250, 194, 245)
    opacity: 0.5;
}

现在#wrapper将具有半透明的颜色。尝试使用正确的不透明度值,直到看起来像你想要的那样。


0
投票

您没有添加图片扩展程序网址

html,body {
    background-image: url("https://vgy.me/u/TpG24N");
    text-align: center;
    height: 100%;

}

另外,需要添加

#wrapper{
 background-color: transparent;
}
© www.soinside.com 2019 - 2024. All rights reserved.