简体   繁体   English

为什么“掩码”类在我的 Bootstrap 5 项目中不起作用?

[英]Why isn't the 'mask' class working in my Bootstrap 5 project?

The latest Bootstrap 5 is giving a tough time in adding class="mask" to my background image.最新的 Bootstrap 5 很难将class="mask"添加到我的背景图像中。 It doesn't even work at all.它甚至根本不起作用。

 <head> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous"> </head> <body> <div class="d-flex justify-content-center align-items-center bg-image"> <img src="https://images.unsplash.com/photo-1489987707025-afc232f7ea0f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80" class="w-100" /> <div class="mask " style="background-color:rgba(0, 0, 0, 0.6) ;"> <div class=" justify-content-center align-items-center b-100 "> <hi class="text-white"> product details </hi> </div> </div> </div> </body>

Mask is a part of Material Design for Bootstrap ( mdbootstrap ), so you need to include its CSS CDN too Mask 是 Material Design for Bootstrap ( mdbootstrap ) 的一部分,所以你也需要包含它的 CSS CDN

<link
  href="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/4.2.0/mdb.min.css"
  rel="stylesheet"
/> 

 <head> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous"> <link href="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/4.2.0/mdb.min.css" rel="stylesheet" /> </head> <body> <div class="d-flex justify-content-center align-items-center bg-image"> <img src="https://images.unsplash.com/photo-1489987707025-afc232f7ea0f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80" class="w-100" /> <div class="mask" style="background-color:rgba(0, 0, 0, 0.6) ;"> <div class="d-flex justify-content-center align-items-center h-100"> <h1 class="text-white"> product details </h1> </div> </div> </div> </body>

 <link rel="stylesheet" href="https://mdbcdn.b-cdn.net/wp-content/themes/mdbootstrap4/docs-app/css/dist/mdb5/standard/core.min.css"> <div class="bg-image"> <img src="https://images.unsplash.com/photo-1489987707025-afc232f7ea0f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80" class="w-100" alt="Louvre Museum" /> <div class="mask" style="background-color: rgba(0, 0, 0, 0.6)"> <div class="d-flex justify-content-center align-items-center h-100"> <p class="text-white mb-0">product details</p> </div> </div> </div>

Fixed the Bootstrap link, and added useful classes to rightly position the text div on the image.修复了 Bootstrap 链接,并添加了有用的类以在图像上正确定位文本 div。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM