1 回答

TA貢獻1775條經驗 獲得超11個贊
最終代碼片段:
header {
? position: relative;
? height: 100vh;
}
.left-side {
? position: relative;
? width: 6.04%;
? height: 76.339vh;
? margin-top: 10.714vh;
}
.content {
? position: relative;
? display: inline-block;
? width: 87.92%;
? height: calc(100% - 10.714vh);
? margin-top: 10.714vh;
}
.hero {
? position: relative;
}
img {
? object-fit: cover;
? width: 100%;
? height: 76.339vh;
}
.right-side {
? width: 6.04%;
? position: relative;
? height: 76.339vh;
? margin-top: 10.714vh;
}
.rotated {
? position: absolute;
? transform: rotate(-180deg);
? bottom: 0;
}
p {
? writing-mode: vertical-lr;
? white-space: nowrap;
? font-size: 1em;
? line-height: 1em;
? letter-spacing: 1px;
? width: 100%;
}
<link rel="stylesheet" />
<link rel="stylesheet" />
<header class="pure-g">
? <div class="left-side">
? </div>
? <div class="content">
? ? <div class="hero">
? ? ? <img src="https://i.picsum.photos/id/830/1680/855.jpg">
? ? </div>
? </div>
? <div class="right-side">
? ? <div class="rotated">
? ? ? <p>Lorem Ipsum</p>
? ? </div>
? </div>
</header>

TA貢獻1843條經驗 獲得超7個贊
header {
? ?position: relative;
? ?height: 100vh;
}
.left-side {
? ?position: relative;
? ?margin-left: 5%;
? ?height: 76.339vh;
? ?margin-top: 10.714vh;
}
.content {
? ?position: relative;
? ?display: inline-block;
? ?width: 87.92%;
? ?height: calc(100% - 10.714vh);
? ?margin-top: 10.714vh;
}
.hero {
? ?width: 100%;
? ?position: relative;
? ?img {
? ? ? ?object-fit: cover;
? ? ? ?width: 100%;
? ? ? ?height: 76.339vh;
? ?}
}
.right-side {
? ? ?margin-right: 5%;
}
.rotated {
?position: absolute;
?bottom: 10%;
?left: 50%;
?transform: translate(-50%, -50%);
? ? ? ?p {
? ? ? ?writing-mode: vertical-lr;
? ? ? ?white-space: nowrap;
? ? ? ?font-size: 1em;
? ? ? ?line-height: 2em;
? ? ? ?letter-spacing: 1px;
? ? ? ?width: 100%;
? ?}
}
歸根結底,我不建議在需要響應式頁面時使用“絕對”來定位元素。
- 1 回答
- 0 關注
- 163 瀏覽
添加回答
舉報