html - 如何用 CSS 制作 4 个角几何对象?
问题描述
如何用 CSS 制作 4 个角几何对象?
body {
background: #d0d0d0;
}
.select {
width: 60px;
height: 60px;
background: white;
display: block;
position: relative;
}
<div class="select">
<div style=" height: 2px; width: 15%; background: red; position: absolute; top: 0; "></div>
<div style=" height: 15%; width: 2px; background: red; position: absolute; top: 0; "></div>
<div style=" height: 2px; width: 15%; background: red; position: absolute; bottom: 0; "></div>
<div style=" height: 15%; width: 2px; background: red; position: absolute; bottom: 0; "></div>
<div style=" height: 2px; width: 15%; background: red; position: absolute; right: 0; top: 0; "></div>
<div style=" height: 15%; width: 2px; background: red; position: absolute; right: 0; top: 0; "></div>
<div style=" height: 2px; width: 15%; background: red; position: absolute; bottom: 0; right: 0; "></div>
<div style=" height: 15%; width: 2px; background: red; position: absolute; bottom: 0; right: 0; "></div>
</div>
解决方案
这是使用线性渐变的解决方案:
div {
height: 100px;
width: 100px;
background: linear-gradient(black, black) top left,
linear-gradient(black, black) top left,
linear-gradient(black, black) top right,
linear-gradient(black, black) top right,
linear-gradient(black, black) bottom left,
linear-gradient(black, black) bottom left,
linear-gradient(black, black) bottom right,
linear-gradient(black, black) bottom right;
background-size: 2px 20px, 20px 2px;
background-repeat: no-repeat;
}
<div></div>
推荐阅读
- java - 是否可以在 Spring Boot 项目中同时使用 DynamoDBMapper 和 DynamoDB 对象?
- python - 无法调用 pyspark udf 函数
- optaplanner - OptaPlanner,在 VariableListener 中改变其他实体的影子变量
- ruby-on-rails - Sidekiq 伪造模式不适用于 rails rspec 测试
- node.js - 无法将标头设置为获取第 3 方 URL 的请求
- reactjs - 在没有危险的SetInnerHTML的情况下在字符串上添加标记
- swift - 为什么 import UIKit/Foundation 在旧项目中有删除线?
- javascript - 如何删除字符串的第一部分?
- asp.net - ASP w/ spa react dotnet build 需要很长时间
- python-3.x - 无法用字符串中的点替换逗号,反之亦然