【发布时间】:2017-09-16 00:21:38
【问题描述】:
我目前正在尝试建立一个投资组合网站。这是我的目标网页创意:
我在这个设计中苦苦挣扎的部分是定位向下箭头,以便它跨越有角度的 div,而不管屏幕宽度如何。
我能做到的最接近的方法是为按钮分配以下值...
position: absolute;
top: 290px;
left: 30%;
这是我的代码:
*,
*:before,
*:after {
box-sizing: border-box;
padding: 0;
margin: 0;
}
section {
width: 100%;
min-height: 400px;
}
.bg-hero {
background: #00C1F7;
position: relative;
}
.bg-dark {
background: #003342;
position: relative;
}
.angled-div::before {
content: '';
width: 100%;
height: 100%;
position: absolute;
background: inherit;
z-index: -1;
bottom: 0;
transform-origin: left bottom;
transform: skewY(-3deg);
z-index: 1;
}
.button {
height: 150px;
width: 150px;
position: absolute;
top: 290px;
left: 30%;
background: #003342;
border-radius: 150px;
z-index: 2;
}
.button span {
width: 100%;
text-align: center;
color: white;
position: absolute;
top: 20px;
font-size: 62px;
}
.button:hover {
cursor: pointer;
background: #004472
}
<section class="bg-hero"></section>
<div class="button"><span>↓</span></div>
<section class="bg-dark angled-div"></section>
问题
如何定位我的 div,使其位于倾斜 div 的一半,并且无论屏幕宽度如何,都保持在倾斜 div 的一半?
【问题讨论】:
-
我向 Paulie 致以最诚挚的歉意,我以为我会得到 CodePen 的链接。以后我一定会遵守规则的。谢谢。
-
没问题,但我认为 JS 是这里的答案。
标签: html css css-position css-transforms