背景透明但不是文本

时间:2018-05-19 19:19:01

标签: html css

我遇到了问题...我想让我的背景图片半透明。但是我希望div中的文本完全可见。有小费吗?提前致谢

reshape

另请注意我在我的文件中使用 bootstrap 。谢谢

1 个答案:

答案 0 :(得分:1)

你错过了很多东西。 首先,结构本身是错误的。使用这么多br标签是不正确的。考虑到您是此门户网站的新用户,您应该对背景不透明度进行更多研究。



.container{
  position: relative;
      /* The image used */
    background-image: url("https://www.elephantsdeli.com/wp-content/uploads/fly-images/1673/elephants-delicatessen-sack-lunch-order-form-hero-image.jpg-1920x1080.jpg");

    /* Full height */
    height:100vh; 
    /* Center and scale the image nicely */
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}
.background {
  height: 100vh;
  background: rgba(255 , 255, 255, 0.5)
}
.text-center {
  padding:50px 0;
}

<div class="container" >
<div class="background">
  <h1 style="font-size: 350%;" class="text-center"><b>It's Lunch-Time!</b></h1>
  </div>
</div>
&#13;
&#13;
&#13;

查看代码段,了解您可以做些什么的小预览/想法。