使用下面的CSS,我試圖使用附加的圖像作爲背景圖像。當我縮小瀏覽器尺寸時,我希望圖像能夠以可擴展的方式調整大小,但是,在600px處,女性的頭部不再可見。換句話說,不是減小圖像內容的比例(即縮小),而是簡單地切掉圖像的右側。有減少圖像的方法,而不是讓css在縮小瀏覽器尺寸時切斷圖像的右側?css中斷而不是縮小
html {
height: 100%;
}
body {
font-family: Lato, sans-serif;
color: #333;
font-size: 15px;
line-height: 23px;
font-weight: 300;
}
.hero-section {
width: 100%;
background-image: url('./3479295472_7d97d686e4_b_couple.jpg');
background-position: 50% 45%;
background-size: cover;
}
<div class="hero-section">
<div class="hero-overlay-section">
<div class="container hero-container w-container">
<h1 class="hero-title" data-ix="hero-fade-in" style="opacity: 1; transform: translateX(0px) translateY(0px) translateZ(0px); transition: opacity 500ms, transform 500ms;">Jim</h1>
<h1 class="and hero-title" data-ix="hero-fade-in-2" style="opacity: 1; transition: opacity 1500ms;">&</h1>
<h1 class="hero-title" data-ix="hero-fade-in-3" style="opacity: 1; transform: translateX(0px) translateY(0px) translateZ(0px); transition: opacity 500ms, transform 500ms;">Karen</h1>
<div class="hero-divider-line" data-ix="hero-fade-in-4" style="opacity: 1; width: 120px; transition: opacity 500ms, width 500ms;"></div>
<div class="hero-date-wrapper">
<h2 class="hero-date-title" data-ix="hero-fade-in-5" style="opacity: 1; transition: opacity 500ms;">November 5th, 2018</h2>
</div>
</div>
</div>
</div>
注意,根據上this SO questionbackground-size
評論應該幫助,但它不是我的情況。
更新:
我自己也嘗試用,得到了相同的結果(女子的頭部被切斷一次我減少瀏覽器的大小)。
background-size: contain;
background-repeat: no-repeat;
請注意,圖片是來自https://www.flickr.com/photos/heroiclife/3479295472/in/album-72157617283714929/ – Leahcim
的創意共享,你可以發佈你的HTML代碼這個問題? –
@MarouenMhiri發佈了它 – Leahcim