我的問題是,這種標記效果很好,而且響應性很強,但是如果用戶在chrome或edge -/+中使用縮放功能,圖像沒有響應,而是保持完全相同的大小。注意:我的圖像是作為背景渲染的。
-- CSS
@media screen and (min-width: 960px) {
.hero-banner {
height: 684px;
overflow: hidden
}
}
.hero-banner [class^="hero-scent_"] {
width: 100%;
padding-top: 320px;
font-size: 16px;
background-repeat: no-repeat;
background-size: auto 230px;
background-position: center top;
background-image: none
}
.hero-banner [class^="hero-scent_"]>.container {
position: relative;
max-width: 1128px;
padding: 0 20px;
margin: 0 auto
}
.hero-banner [class^="hero-scent_"] .copy {
max-width: 493px
}
.hero-banner [class^="hero-scent_"] h2 {
margin: 0 0 0.5em;
font-size: 16px;
font-weight: 400;
text-transform: uppercase;
color: var(--scent-color)
}
.hero-banner [class^="hero-scent_"] h1 {
margin: 0 0 0.5em;
font-size: 36px;
font-weight: 300
}
.hero-banner [class^="hero-scent_"] .links p {
margin-bottom: 0
}
.hero-banner [class^="hero-scent_"] .btn-link {
color: var(--scent-color)
}
.hero-banner [class^="hero-scent_"] .image {
position: absolute;
right: 0;
left: 0;
top: -381.33px;
width: auto;
height: auto;
max-height: 381.33px;
margin-top: -50px
}
@media screen and (min-width: 768px) {
.hero-banner [class^="hero-scent_"] {
background-size: 100% auto
}
.hero-banner [class^="hero-scent_"] .image {
top: -340px
}
}
@media screen and (min-width: 960px) {
.hero-banner [class^="hero-scent_"] {
height: 684px;
padding: 0;
background-size: auto 551px;
background-position: center bottom 133px;
font-size: 20px
}
.hero-banner [class^="hero-scent_"]>.container {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
height: 549px
}
.hero-banner [class^="hero-scent_"] h2 {
font-size: 18px
}
.hero-banner [class^="hero-scent_"] h1 {
font-size: 54px
}
.hero-banner [class^="hero-scent_"] .image {
top: auto;
left: auto;
right: 0;
max-height: 1200px;
width: 1300px;
padding-top: 20px;
margin: 0
}
}
@media screen and (min-width: 1366px) {
.hero-banner [class^="hero-scent_"] {
background-size: 100% auto
}
}
body:not(.no-js) .hero-banner .hero-scent_microban_bkgrnd {
margin-top: -30px;
background-image: url(../img/home/bg_microban_overlay1.png), url(../img/home/bg_hero_microban_bkgrnd.png);
background-size: 96%, 100%;
background-repeat: no-repeat, no-repeat;
background-position: center 40%, center
}
body:not(.no-js) .hero-banner .hero-scent_microban_bkgrnd3 {
margin-top: -30px;
background-image: url(../img/home/bg_hero_microban_bkgrnd3_a.jpg);
background-size: 100%;
background-repeat: no-repeat;
background-position: center
}
body:not(.no-js) .hero-banner .hero-scent_microban_bkgrnd2 {
margin-top: -30px;
background-image: url(https://i.postimg.cc/3r4m51TR/bg-microban-overlay2.png), url(https://i.postimg.cc/Twn7t6C8/bg-hero-microban-bkgrnd.png);
background-size: 96%, 100%;
background-repeat: no-repeat, no-repeat;
background-position: left, center
}
.hero-banner [class^="hero-scent_"] .btn-link:hover {
color: #00235b
}
.hero-banner .tns-nav {
display: block;
margin-top: 60px
}
@media screen and (min-width: 960px) {
.hero-banner .tns-nav {
margin-top: -100px
}
}
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<div class="hero-banner">
<div class="hero-slider">
<div class="hero-scent_microban_bkgrnd2"></div>
<div class="hero-scent_microban_bkgrnd3"></div>
<div class="hero-scent_microban_bkgrnd"></div>
</div>
</div>