如何在 CSS 中创建箭头(3 行)?
How to create arrows (with 3 lines) in CSS?
上图显示了我希望它们看起来像的样子:
我创建了一些目前看起来像这样的箭头:
这里是 fiddle 演示:
https://jsfiddle.net/yokeshsharma/a94a1grk/
.arrow {
display: inline-block;
font-style: normal;
position: relative;
width: 0.8em;
height: 0.8em;
border-right: 0.4em solid black;
border-top: 0.4em solid black;
transform: rotate(-45deg);
left: 16px;
top: 18px;
}
.up{
transform: rotate(-45deg);
}
.down{
transform: rotate(135deg);
}
.left{
transform: rotate(-135deg);
}
.right{
transform: rotate(45deg);
}
<div class="up arrow">
</div>
<div class="down arrow">
</div>
<div class="left arrow">
</div>
<div class="right arrow">
</div>
我已经搜索了其他问题,其中大部分是专门关于创建没有我已经创建的中心线的三角形和箭头的。
但是我无法在两者之间创建线,请帮忙!
尝试这样的事情
.icon {
height: 100px;
width: 100px;
border-radius: 10px;
background: #323335;
text-align: center;
display: inline-block;
margin: 5px;
}
.arrow {
height: 35px;
position: relative;
width: 10px;
background: white;
display: inline-block;
top: 50%;
transform: translateY(-50%);
}
.arrow:before {
content: " ";
width: 10px;
background: white;
height: 35px;
position: absolute;
top: -10px;
transform: rotate(50deg);
left: -10px;
}
.arrow:after {
content: " ";
width: 10px;
background: white;
height: 35px;
position: absolute;
top: -10px;
transform: rotate(-50deg);
right: -10px;
}
.arrow-down {
transform: rotate(-180deg) translateY(50%);
bottom: 50%;
}
<div class="icon">
<div class="arrow"> </div>
</div>
<div class="icon">
<div class="arrow arrow-down"> </div>
</div>
看看这个
.container {
width:100px;
height:100px;
margin: 20px auto;
}
.rect {
width: 50px;
height: 50px;
top:35px;
position: relative;
background-color: #777;
transform: rotate(45deg);
}
.rect1 {
width: 50px;
height: 50px;
position: relative;
background-color: #fff;
transform: rotate(45deg);
}
.v-rule {
width: 10px;
height: 50px;
position: relative;
background-color: #777;
top:-60px;
margin-left:20px
}
<div class="container">
<div class="rect"></div>
<div class="rect1"></div>
<div class="v-rule"></div>
</div>
上图显示了我希望它们看起来像的样子:
我创建了一些目前看起来像这样的箭头:
这里是 fiddle 演示:
https://jsfiddle.net/yokeshsharma/a94a1grk/
.arrow {
display: inline-block;
font-style: normal;
position: relative;
width: 0.8em;
height: 0.8em;
border-right: 0.4em solid black;
border-top: 0.4em solid black;
transform: rotate(-45deg);
left: 16px;
top: 18px;
}
.up{
transform: rotate(-45deg);
}
.down{
transform: rotate(135deg);
}
.left{
transform: rotate(-135deg);
}
.right{
transform: rotate(45deg);
}
<div class="up arrow">
</div>
<div class="down arrow">
</div>
<div class="left arrow">
</div>
<div class="right arrow">
</div>
我已经搜索了其他问题,其中大部分是专门关于创建没有我已经创建的中心线的三角形和箭头的。 但是我无法在两者之间创建线,请帮忙!
尝试这样的事情
.icon {
height: 100px;
width: 100px;
border-radius: 10px;
background: #323335;
text-align: center;
display: inline-block;
margin: 5px;
}
.arrow {
height: 35px;
position: relative;
width: 10px;
background: white;
display: inline-block;
top: 50%;
transform: translateY(-50%);
}
.arrow:before {
content: " ";
width: 10px;
background: white;
height: 35px;
position: absolute;
top: -10px;
transform: rotate(50deg);
left: -10px;
}
.arrow:after {
content: " ";
width: 10px;
background: white;
height: 35px;
position: absolute;
top: -10px;
transform: rotate(-50deg);
right: -10px;
}
.arrow-down {
transform: rotate(-180deg) translateY(50%);
bottom: 50%;
}
<div class="icon">
<div class="arrow"> </div>
</div>
<div class="icon">
<div class="arrow arrow-down"> </div>
</div>
看看这个
.container {
width:100px;
height:100px;
margin: 20px auto;
}
.rect {
width: 50px;
height: 50px;
top:35px;
position: relative;
background-color: #777;
transform: rotate(45deg);
}
.rect1 {
width: 50px;
height: 50px;
position: relative;
background-color: #fff;
transform: rotate(45deg);
}
.v-rule {
width: 10px;
height: 50px;
position: relative;
background-color: #777;
top:-60px;
margin-left:20px
}
<div class="container">
<div class="rect"></div>
<div class="rect1"></div>
<div class="v-rule"></div>
</div>