gpt4 book ai didi

html - 如何将两个背景图像添加到同一个标题?

转载 作者:搜寻专家 更新时间:2023-10-31 08:40:11 26 4
gpt4 key购买 nike

我有带背景图片的页眉,我希望页眉有相同的背景但是两次,效果应该是这样的。

为了获得底部颜色,我向一张图片添加了不透明度,例如 0.5,但不透明度会影响标题中的所有内容,我希望文本和 Logo 不受标题横幅的不透明度影响。

/* Marketing business main header */
.marketing-navbar_items {
font-family: Helvetica Neue;
font-size: 30px;
font-weight: normal;
color: #FFFFFF;
}

.marketing-main-header_banner {
background-image: url("https://svgshare.com/i/8KR.svg");
background-size: auto 1199px;
background-repeat: no-repeat;
background-position: center -250px;
position: relative;
height: 949px;


}
.sample {
background-image: url("https://svgshare.com/i/8KR.svg");
background-size: auto 1199px;
background-repeat: no-repeat;
background-position: center -250px;
position: absolute;
height: 949px;
opacity: 0.5;


}
.marketing-main-header_details {

display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
margin-top: 30px;
}

.marketing-main-header_description p {
font-size: 30px;
font-family: HeaderFont;
color: white;
/* width: 55%; */
text-align: center;
margin: 50px 0px;
}

.marketing-main-header_button-primary {
background-color: white;
background-size: 150px 100px;
font-size: 16px;
border-color: transparent;
color: #4834D4;
font-family: Roboto Regular;
width: 373px;
height: 92px;

}

.marketing-main-header_button {
margin-top: 50px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>

<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

<div class="container-fluid marketing-main-header">
<div class="marketing-main-header_banner">
<div class="sample">
<nav class="navbar navbar-expand-lg navbar-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto marketing-navbar">
<li class="marketing-navbar_items nav-item">
<a class="marketing-nav-link nav-link" href="#">Dla kogo </a>
</li>
<li class="marketing-navbar_items nav-item">
<a class="marketing-nav-link nav-link" href="#">Agenda</a>
</li>
<li class="marketing-navbar_items nav-item">
<a class="marketing-nav-link nav-link" href="#">Prowadzacy</a>
</li>
<li class="marketing-navbar_items nav-item">
<a class=" marketing-nav-link nav-link " href="#">Faq</a>
</li>
<li class="marketing-navbar_items nav-item">
<a class="marketing-nav-link nav-link " href="#">Kontakt</a>
</li>
<li class="marketing-navbar_items nav-item">
<a class="marketing-nav-link nav-link " href="#">Kompetencje</a>
</li>
</ul>
</div>
</nav>


<div class="marketing-main-header_details">
<div class="marketing-main-header_logo">
<img src="https://thumb.ibb.co/hPrhZp/logo_mib.png">
</div>
<div class="marketing-main-header_title">
<h1>SZKOLENIA</h1>
</div>
<div class="marketing-main-header_description">
<p>Lorem ipsum dolor sit amet, an pro dicta maiorum recusabo.</p>
</div>
<div class="marketing-main-header_sub-description">
<p>Lorem ipsum dolor sit amet, an pro dicta maiorum recusabo.</p>
</div>

<div class="marketing-main-header_button">
<button type="button" class="marketing-main-header_button-primary">Poznaj Agende</button>
</div>
</div>
</div>
</div>
</div>

我需要做什么才能获得预期的结果(文本不应受到不透明度的影响)?

最佳答案

.marketing-navbar_items 上制作一个 :before 伪代码,如所示示例。这样,它就不会影响其子级的不透明度(因为它没有任何透明度)。

/* Marketing business main header */
.marketing-navbar_items {
font-family: Helvetica Neue;
font-size: 30px;
font-weight: normal;
color: #FFFFFF;
}

.marketing-main-header_banner, .marketing-main-header_banner:before {
background-image: url("https://svgshare.com/i/8KR.svg");
background-size: auto 1199px;
background-repeat: no-repeat;
background-position: center -250px;
height: 949px;
}

.marketing-main-header_banner {
position: relative;
}

.marketing-main-header_banner:before {
content: "";
display: block;
width: 100%;
position: absolute;
top: 50px;
opacity: 0.5;
}

.marketing-main-header_details {

display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
margin-top: 30px;
}

.marketing-main-header_description p {
font-size: 30px;
font-family: HeaderFont;
color: white;
/* width: 55%; */
text-align: center;
margin: 50px 0px;
}

.marketing-main-header_button-primary {
background-color: white;
background-size: 150px 100px;
font-size: 16px;
border-color: transparent;
color: #4834D4;
font-family: Roboto Regular;
width: 373px;
height: 92px;

}

.marketing-main-header_button {
margin-top: 50px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>

<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

<div class="container-fluid marketing-main-header">
<div class="marketing-main-header_banner">
<div class="sample">
<nav class="navbar navbar-expand-lg navbar-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto marketing-navbar">
<li class="marketing-navbar_items nav-item">
<a class="marketing-nav-link nav-link" href="#">Dla kogo </a>
</li>
<li class="marketing-navbar_items nav-item">
<a class="marketing-nav-link nav-link" href="#">Agenda</a>
</li>
<li class="marketing-navbar_items nav-item">
<a class="marketing-nav-link nav-link" href="#">Prowadzacy</a>
</li>
<li class="marketing-navbar_items nav-item">
<a class=" marketing-nav-link nav-link " href="#">Faq</a>
</li>
<li class="marketing-navbar_items nav-item">
<a class="marketing-nav-link nav-link " href="#">Kontakt</a>
</li>
<li class="marketing-navbar_items nav-item">
<a class="marketing-nav-link nav-link " href="#">Kompetencje</a>
</li>
</ul>
</div>
</nav>


<div class="marketing-main-header_details">
<div class="marketing-main-header_logo">
<img src="https://thumb.ibb.co/hPrhZp/logo_mib.png">
</div>
<div class="marketing-main-header_title">
<h1>SZKOLENIA</h1>
</div>
<div class="marketing-main-header_description">
<p>Lorem ipsum dolor sit amet, an pro dicta maiorum recusabo.</p>
</div>
<div class="marketing-main-header_sub-description">
<p>Lorem ipsum dolor sit amet, an pro dicta maiorum recusabo.</p>
</div>

<div class="marketing-main-header_button">
<button type="button" class="marketing-main-header_button-primary">Poznaj Agende</button>
</div>
</div>
</div>
</div>
</div>

关于html - 如何将两个背景图像添加到同一个标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52344610/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com