【发布时间】:2019-01-16 09:57:46
【问题描述】:
如何让这个箭头框响应?
这是我现在的代码:
<div class="arrow-box"></div>
.arrow-box {
border-bottom: 0;
position: relative;
background: #fff;
border: 1px solid #13aac5;
border-bottom: 0;
width: 1000px;
height: 240px;
box-shadow: 1px 1px 21px 0px rgba(50, 50, 50, 0.3);
&:before {
position: absolute;
bottom: -63px;
display: inline-block;
width: 0;
height: 0;
border-style: solid;
border-width: 62px 501px 0 501px;
border-color: #13aac5 transparent transparent transparent;
content: '';
}
&:after {
position: absolute;
display: inline-block;
width: 0;
height: 0;
border-style: solid;
border-width: 62px 500px 0 500px;
border-color: #fff transparent transparent transparent;
content: '';
bottom: -62px;
}
}
你可以看看这个fiddle
它在桌面上按预期工作,但没有响应,谁能帮我让它响应?
【问题讨论】:
-
您正在为宽度使用硬编码的基于像素的值。只需将这些替换为基于百分比的值即可。
-
@ObsidianAge 我已将百分比值放在媒体查询中箭头的边框宽度上,但它不起作用。
-
我建议使用嵌入的 SVG 图像作为箭头,而不是尝试使用 CSS 构建它
-
@Flying 我已经尝试过使用背景图片,但是因为我必须在其中放置一些段落和项目列表,并且背景图片没有正确响应,所以我必须处理它使用 CSS。
-
@vinnlee 实际上,可以不为整个元素应用背景图像,而只为
::after应用背景图像,它代表元素下方的箭头。它将使您的主要元素独立于图像,但允许您创建所需的箭头。
标签: html css sass responsive-design