Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 更改Jumbotron不透明度并使其全宽而不影响字体和按钮_Jquery_Html_Css - Fatal编程技术网

Jquery 更改Jumbotron不透明度并使其全宽而不影响字体和按钮

Jquery 更改Jumbotron不透明度并使其全宽而不影响字体和按钮,jquery,html,css,Jquery,Html,Css,想知道如何更改Jumbotron不透明度并使其全宽而不影响字体和按钮的不透明度吗 .jumbotron-special{ text-align: center; background-attachment: scroll; background-image: image-url('header-bg.jpg'); background-position: center center; background-repeat: none; -webkit

想知道如何更改Jumbotron不透明度并使其全宽而不影响字体和按钮的不透明度吗

.jumbotron-special{
    text-align: center;
    background-attachment: scroll;
    background-image: image-url('header-bg.jpg');
    background-position: center center;
    background-repeat: none;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    background-size: cover;
    -o-background-size: cover;
    // how to only make background-image-opacity: 0.3;
}

您可以在另一个元素中添加背景,并仅降低该元素的不透明度:

.jumbotron-special {
   position: relative;
}
.jumbotron-special:after {
    content : "";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    background-image: url('header-bg.jpg'); 
    width: 100%;
    height: 100%;
    opacity : 0.3;
    z-index: -1;
}

看下面的小提琴:

基本上,让一个父元素管理页面流,使其相对,并为后台创建一个子元素,为内容创建一个子元素(顺序因z-index而重要,除非您手动更改它)。然后,将子对象绝对定位,并填充整个父对象

<div class="jumbotron">
    <div class="bg">
        I'm in the background.
    </div>
    <div class="content">
        <h1>Important stuff!</h1>
        <button>Yup.</button>
    </div>
</div>

不知怎的,它不起作用了,jumbotron现在没有任何背景图像。它会受到其他代码的影响吗?
.jumbotron {
    width: 100%;
    height: 400px;
    position: relative;
}

.jumbotron .bg {
    opacity: 0.10;
    background-color: orange;
    position: absolute;
    width: 100%;
    height: 100%;
 }

.jumbotron .content {
    position: absolute;
    width: 100%;
    height: 100%;
}