背景上有四条线。它们在整体区域中可见,但不会出现在图片上。
如何实现这个效果?
背景上有四条线。它们在整体区域中可见,但不会出现在图片上。
如何实现这个效果?
body{
background: linear-gradient(90deg, #eee 1%, transparent 1%) 1px 0, #fff;
background-size: 200px 1px;
}
演示: https://codepen.io/anon/pen/VMzwNw
这个网站可以生成许多其他背景 -> http://lea.verou.me/css3patterns/#stairs
background-position: -1px
来移除最靠近浏览器边缘的左侧线条,并将 background-size
设置为 calc((100% / 8) + 0.2px)
,这样可以移除最靠近浏览器边缘的右侧线条。我还将渐变宽度设置为 0.5%
而不是 1%
,以使线条更细。 - Martin Jamesdiv {
height: 100px;
background-color: transparent;
background-size: 25% 100%;
background-repeat: repeat-x;
background-image: linear-gradient(to right, black 1px, transparent 1px);
background-position: 12.5%;
}
<div>
</div>
background-size
,background-position
和background-repeat
组合在一起使垂直线重复。div {
height: 100px;
background-color: transparent;
background-size: 25% 100%, cover;
background-repeat: repeat-x, no-repeat;
background-image: linear-gradient(to right, black 1px, transparent 1px), url(http://lorempixel.com/400/200/);
background-position: 12.5%, center;
}
<div>
</div>