[英]Linear gradient above <div> tag with CSS
I'm looking to add a gradient to the top of some independently scrolling tab content so the content isn't sliced off at the bottom of the tabs when you scroll up.我希望在一些独立滚动的选项卡内容的顶部添加一个渐变,这样当您向上滚动时,内容不会在选项卡底部被切掉。 The goal is to have the content fade to white behind the tabs above.目标是让内容在上面的选项卡后面淡化为白色。 How would I go about adding this gradient so that it lays above the tab content and achieves this effect in the best way?我将如何 go 添加此渐变以使其位于选项卡内容之上并以最佳方式实现此效果? The images below better explain the effect I am going for:下面的图片更好地解释了我想要的效果:
Obviously I wouldn't want it covering up the first card but I figured I could resize it between the tabs and the card so no content is covered unless you scroll.显然我不希望它覆盖第一张卡片,但我想我可以在选项卡和卡片之间调整它的大小,所以除非你滚动,否则不会覆盖任何内容。
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous"> <div class="col-xs-12 col-sm-12 col-md-6"> <div class="row r-tabs"> <div class="tab-bar"> <button class="bar-item tab-active" onclick="openTab(event, 'section1')">Summary</button> <button class="bar-item" onclick="openTab(event, 'section2')">Images</button> <button class="bar-item" onclick="openTab(event, 'section3')">Contact</button> <button class="bar-item" onclick="openTab(event, 'section4')">Help</button> </div> </div> <div id="section1" class="tab-content"> <div class="card"> <div class="card-body model-btn-card"> <div class="viewing text-black"> </div> </div> </div>
You can style the:before element for the div, something like:您可以为 div 设置:before 元素的样式,例如:
div {
position: relative;
}
div: before {
content: '';
top: -2px;
left: 0;
width: 100%;
height: 15px;
background: linear-gradient(to top, transparent, #fff);
}
Didn't test it, but something like this should work.没有测试它,但这样的东西应该可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.