gpt4 book ai didi

html - 使用@media 设置的着色填充区域

转载 作者:行者123 更新时间:2023-11-28 03:41:19 25 4
gpt4 key购买 nike

对于我正在使用的可湿性粉剂

@media (min-width: 768px) {
section {
padding: 50px 0;
}
}

用于在多个部分之间自动填充。现在,对于一个部分,我想在它前面添加一个背景图像和一个灰色透明框:

section {
padding: 100px 0; #which does not do anything, can change it to random values.
}
section .background1 {
background-color: #222222;
background-image: url('../img/bg.jpg');
background-repeat: no-repeat;
background-attachment: scroll;
background-position: center center;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
section .bg-layer {
background-color: rgba(50,50,50, 0.6);
top: 0 ;
left: 0;
width: 100%;
height: 100%;
}

我的 html 代码如下所示,里面有一些文本等:

<section>
<div class="background1">
<div class="bg-layer">
<div class="container">

这在原则上工作正常,但填充区域没有填充背景图像,我无法做到这一点。所以我基本上希望图像和灰色区域延伸到这一节的一般填充区域。任何人都可以帮助或描述最好的解决方法吗?非常感谢!

最佳答案

我想这就是您想要实现的目标。

section {
padding: 100px 0;
background-color: #dddddd;
}
section h2.section-heading {
text-transform: none;
font-size: 40px;
margin-top: 10px;
margin-bottom: 15px;
}
section h3.section-subheading {
font-size: 16px;
font-family: "Droid Serif", "Helvetica Neue", Helvetica, Arial, sans-serif;
text-transform: none;
font-style: italic;
font-weight: 400;
margin-bottom: 75px;
}
section .background1 {
background-color: #ffffff;
background-image: url('../img/bg.jpg');
background-repeat: no-repeat;
background-attachment: scroll;
background-position: center center;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
section .bg-layer {
background-color: rgba(50,50,50, 0.6);
padding: 50px 0;
}
section h2.bg-section-heading {
color: white;
text-transform: none;
font-size: 40px;
margin-top: 10px;
margin-bottom: 15px;
}
section h3.bg-section-subheading {
color: white;
font-size: 16px;
font-family: "Droid Serif", "Helvetica Neue", Helvetica, Arial, sans-serif;
text-transform: none;
font-style: italic;
font-weight: 400;
}

@media (min-width: 768px) {
section {
padding: 50px 0;
}
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: "Montserrat", "Helvetica Neue", Helvetica, Arial, sans-serif;
text-transform: uppercase;
font-weight: 700;
}
.bg-darkest-gray {
background-color: #222222;
padding: 0;
}

Fiddle

关于html - 使用@media 设置的着色填充区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44202992/

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