html - 如何创建带有方形之字形的水平规则?
问题描述
你能帮我用这种 hr 风格,比如 zip,只有 css 我什至不知道如何开始,当然它写道我需要使用 2 个渐变。
解决方案
像下面
.box {
height:15px;
background:
repeating-linear-gradient(90deg,blue 0 5px,#0000 0 10px) top, /* top gradient*/
repeating-linear-gradient(90deg,#0000 0 5px,blue 0 10px) bottom, /* bottom gradient*/
linear-gradient(blue 0 0) center; /* a line in the middle */
background-size:100% calc(100%/3); /* the 3 with the same size */
background-repeat:no-repeat;
}
<div class="box"></div>
或者
.box {
height:15px;
background:
repeating-linear-gradient(90deg,blue 0 5px,#0000 0 10px) top,
repeating-linear-gradient(90deg,#0000 0 5px,blue 0 10px) bottom;
background-size:100% calc(2*100%/3);
background-repeat:no-repeat;
}
<div class="box"></div>
另一个简化版本:
.box {
height:15px;
background:
linear-gradient(90deg,blue 50%,#0000 0) top,
linear-gradient(90deg,#0000 50%,blue 0) bottom;
background-size:10px calc(2*100%/3);
background-repeat:repeat-x;
}
<div class="box"></div>
推荐阅读
- android - 无法执行 aapt :app:processDebugResources FAILED
- javascript - 通过扩展点击页面上的一个元素,并在弹出窗口中获取点击的元素数量
- shell - jq显示一个json文件的不同字段
- class - 以不同的单位重用对象的属性
- sql - 在 PeopleSoft 查询管理器中按会计年度确定折旧
- python - 即使条件不满足,getattr 也可以访问第三个参数
- sql - 如何在 SQL 中对 3 个联合进行 GROUP BY
- java - onCreate 的 java.lang.NoSuchMethodException
- elasticsearch - Elasticsearch 删除旧数据
- java - Gson - 从 Json 解析为类型化的 ArrayList