css arrow box html,CSS中制作三角形

在CSS中制作三角形是非常常见的UI任务。

使用border边框制作CSS三角形

HTML

Four Direction of the Arrows


Arrow Illusion

SASS// Arrows

.arrow-up {

width: 0;

height: 0;

border-right: 16px solid transparent;

border-left: 16px solid transparent;

border-bottom: 20px solid #8888e8;

}

.arrow-right {

width: 0;

height: 0;

border-top: 16px solid transparent;

border-bottom: 16px solid transparent;

border-left: 20px solid #e888a3;

}

.arrow-down {

width: 0;

height: 0;

border-right: 16px solid transparent;

border-left: 16px solid transparent;

border-top: 20px solid #f7df6c;

}

.arrow-left {

width: 0;

height: 0;

border-top: 16px solid transparent;

border-bottom: 16px solid transparent;

border-right: 20px solid #8de698;

}

// Border behavior

.arrow-box {

width: 0;

height: 0;

border-top: 40px solid #f7df6c;

border-right: 40px solid #8de698;

border-bottom: 40px solid #8888e8;

border-left: 40px solid #e888a3;

&.has-width {

width: 20px;

height: 20px;

}

}

// Formats

body {

padding: 50px 30px;

}

.arrow-wrapper {

display: flex;

align-items: center;

justify-content: center;

margin: 30px 0 0;

> * {

margin: 0 20px;

}

}

.title {

text-transform: uppercase;

font-size: 1rem;

color: rgba(0,0,0,0.3);

text-align: center;

font-weight: 400;

margin: 0;

}

.arrow-boxes {

display: flex;

align-items: center;

justify-content: center;

margin: 30px 0 0;

> * {

margin: 0 20px;

}

}

hr {

border: none;

height: 1px;

background: rgba(0,0,0,0.1);

margin: 60px 0;

}

8a6cc582768cdce91016e1d9565db323.png

要创建边框,则完全可以单独设置它们的样式(上、右、下、左)。两个独立的侧面以对角线(45度)的方式相互连接,就形成了一个正方形。

css创建三角形,元素宽度和高度都应设为0。如果要做一个箭头向上的三角形,则需要为边框底部着色即可。

css创建三角形,着色的一面的对角方向可以不写任何样式,其它两个方向需写上透明transparent。

使用HTML实体制作CSS三角形

使用HTML实体是最基本的解决方案,但它可以在更简单的情况下工作。要使用它们,请将其中一个添加到:: before或:: after伪元素的content属性中。◄ : ◄

► : ►

▼ : ▼

▲ : ▲

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值