如何为具有相对位置的 div 分配完整高度 -
div {
border: 1px solid;
box-sizing: border-box;
}
.home-gallery {
position: relative;
height: 100%;
width: 100%;
}
.rc-contain {
position: absolute;
bottom: 0;
height: 100%;
width: 100%;
}
.rc-slider {
position: absolute;
top: 0;
height: 100%;
width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
<div class="home-gallery">
<div class="rc-contain">
....
</div>
<div class="rc-slider">
....
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
但我的家庭画廊 div 没有占据全高。当我专注于响应式设计时,如何动态分配家庭画廊的高度。
有一个块,其中靠近结尾的文本逐渐消失。这是通过使用完成::after
,这是考虑linear-gradient
从透明颜色的背景颜色。最近注意到,在当前版本的浏览器中,一切都很好,除了 safari(在第 11 版中,太糟糕了)。Autoprefix 不是解决方案(他在这里,不需要)。
我的代码:
* {
margin: 0;
padding: 0;
}
body {
display: flex;
min-height: 100vh;
}
p {
margin: auto;
width: 40vw;
height: 40vh;
max-width: 300px;
max-height: 300px;
overflow: hidden;
position: relative;
}
p::after {
content: '';
display: block;
position: absolute;
bottom: 0;
width: 100%;
height: 50%;
background-image: linear-gradient(transparent 0, white 100%);
}
Run Code Online (Sandbox Code Playgroud)
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur vel urna efficitur, tempor felis eu, lacinia sem. Nulla lacinia …
Run Code Online (Sandbox Code Playgroud)