4
我有一個分成兩部分的頁面部分。左側是行容器中的內容,而另一半是容器外的圖像。本部分有一個漸變BG,可以幫助實現筆記本電腦坐在窗臺上的效果。這裏是什麼,我試圖完成一個屏幕截圖:背景中的CSS漸變使用截面尺寸縮放
(https://monosnap.com/file/fX2jGJ9HcEuw6xsSFK8TzbdO023RMd)
目標:
- 有圖像佔用視口的50%,並觸及右屏幕邊的 。內容必須留在內容容器(行)中
- 漸變保持在屏幕截圖所示的位置。
- 該部分在縮放時響應高度。
HTML:
<section class="full-width snocruapp-offtheslopes tgs-section-titles half-and-half-section hide-for-small-only">
<div class="row">
<div class="large-6 medium-6 columns">
<div class="copy--with-image copy--align-left">
<div class="tgs-section-titles"><h3>Off the Slopes Counterpart</h3>
<hr>
<p>One important piece of the user experience was that the website functioned more than just a marketing tool. We developed the dashboard area so when users logged in, they were provided with personalized data, leaderboard stats and track heat mapping.</p>
</div>
</div>
</div><!--end large 6 right -->
<div class="large-6 medium-6 columns"></div>
<div class="image--align-to-window image--align-right">
<picture>
<source srcset="http://sandbox.techgrayscale.com/wp-content/uploads/2016/03/slopes-image2.png" media="(min-width: 1024px)">
<img srcset="http://sandbox.techgrayscale.com/wp-content/uploads/2016/03/sno_mbl_counterpart_nograd.png" alt="Half Image">
</picture>
</div>
</div><!--end row -->
</section>
我創建了一個基礎網格內容,以便該內容在相應的地方停留。 接下來,我創建了一個圖像div,並絕對定位圖像以覆蓋網格的另一半。
CSS:
* {
margin: 0;
padding:0;
}
section {
display: block;
overflow: hidden;
}
.full-width {
width: 100%;
margin-left: auto;
margin-right: auto;
max-width: initial;
}
.half-and-half-section {
position: relative;
margin: 50px 0;
}
.half-and-half-section .image--align-to-window {
position: absolute;
top: 0;
}
.half-and-half-section .image--align-right {
right: 0;
width: 50%;
}
.snocruapp-offtheslopes {
background: #ffffff;
background: linear-gradient(to bottom, #ffffff 0%, #e2e2e2 75%, #ffffff 75%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ffffff',GradientType=0);
}
我施加的CSS梯度的部分。該圖像是絕對定位的,因此它不會成爲該容器的一部分,並且可以延伸到視口的右側。
我遇到了幾個問題。
- 除非我爲該部分添加填充圖像,否則圖像會被遮擋。
- 我不知道如何讓漸變留在同一個地方(調整大小與圖像成比例)隨着視口重新調整大小。
我真的很茫然,如何在屏幕截圖中獲得functanlity和設計。
你能否更新codepen鏈接? 404 – actimel