我有一个<main>
HTML元素,该元素占页面上<body>
元素的80%,最大宽度值为max-width: 1220px
。
在此<main>
元素之外,我还有一个小的SVG箭头-CSS calc()
函数是否可以具有此功能,因此它始终位于主元素上区域的中间左手边?
如果我没有最大宽度属性,我可以做left: 10%
,但这只能工作到main
元素达到最大宽度为止。
下面是完整的代码,我设法获取了它,使其与main元素的左侧对齐,但是我无法获取,因此它位于左侧空白的一半。我认为CSS中可能无法实现。
Codepen:https://codepen.io/emilychews/pen/bGEJjwX
注意1::当查看以下代码段时,由于最大宽度值,您需要整页查看它。
注意2:下图说明了我正在尝试做的事情。
main {
position: relative;
margin: 0 auto;
width: 80%;
padding: 6rem 0;
background: red;
height: 100vh;
max-width: 1220px;
}
.down-arrow {
position: absolute;
width: 1rem;
height: 1rem;
bottom: 25vh;
/* THIS IS THE BIT I NEED HELP WITH */
left: calc((100% - 1220px) / 2);
}
<main>
<div class="row"></div>
</main>
<svg class="down-arrow" aria-hidden="true" viewBox="0 0 410.95 355.89">
<polygon fill="#000" points="205.47 354.89 410.08 0.5 0.87 0.5 205.47 354.89" /></svg>