我试图使一些HTML和CSS看起来像收据。我希望这张收据的底部看起来像是被撕掉的。我已经得到了一个::后风格,看起来接近我想要的,但在移动的设备上,它是显示与一些奇怪的线条。我需要一个响应式的设计,看起来不错的移动的屏幕尺寸。
这是我正在寻找的设计:
下面是我的尝试,它显示出奇怪的线条:
下面是我正在使用的代码:
body {
background: black;
}
.StyledReceipt {
background-color: #fff;
width: 22rem;
position: relative;
padding: 1rem;
box-shadow: 0 -0.4rem 1rem -0.4rem rgba(0, 0, 0, 0.2);
}
.StyledReceipt::after {
background-image: linear-gradient(135deg, #fff 0.5rem, transparent 0),
linear-gradient(-135deg, #fff 0.5rem, transparent 0);
background-position: left-bottom;
background-repeat: repeat-x;
background-size: 1rem;
content: '';
display: block;
position: absolute;
bottom: -1rem;
left: 0;
width: 100%;
height: 1rem;
}
<div class="StyledReceipt">Test</div>
1条答案
按热度按时间yqyhoc1h1#
我有一个生成这种形状(https://css-generators.com/custom-borders/)的生成器,它也适用于任何背景。一个梯度,不需要伪元素。
如果你想要阴影,你可以像下面这样做: