美文网首页
纯CSS写三角形样式集合(原理解析)

纯CSS写三角形样式集合(原理解析)

作者: 落魂灬 | 来源:发表于2018-11-16 17:42 被阅读13次

一、实现原理

在css3中,我们主要使用的是一个transparent的属性,意思是透明的,比如我们将字体设置为黑色会写color:black,那么如果想把字体的颜色设置为透明,我们可以写color:transparent。同理background-color:transparent可以设置背景为透明。

二、 8种三角形实现实例

1.triangle up 上三角形

#triangle-up{
  width:0;
  height:0;
  border-left:50px solid transparent;
  border-right:50px solid transparent;
  border-bottom:100px solid black;
}

2.triangle down 下三角形

#triangle-down{
  width:0;
  height:0;
  border-left:50px solid transparent;
  border-right:50px solid transparent;
  border-top:100px solid black;
}

3.triangle left 左三角形

#triangle-left{
  width:0;
  height:0;
  border-top:50px solid transparent;
  border-bottom:50px solid transparent;
  border-right:100px solid black;
}

4.triangle right 右三角形

#triangle-right{
  width:0;
  height:0;
  border-top:50px solid transparent;
  border-bottom:50px solid transparent;
  border-left:100px solid black;
}

5.triangle top left 左上三角形

#triangle-topleft{
  width:0;
  height:0;
  border-top:100px solid black;
  border-right:100px solid transparent;
}

6.triangle top right 右上三角形

#triangle-topright{
  width:0;
  height:0;
  border-top:100px solid black;
  border-left:100px solid transparent;
}

7.triangle bottom left 左下三角形

#triangle-bottomleft{
  width:0;
  height:0;
  border-bottom:100px solid black;
  border-right:100px solid transparent;
}

8.triangle bottom right 右下三角形

#triangle-bottomright{
  width:0;
  height:0;
  border-bottom:100px solid black;
  border-left:100px solid transparent;
}

相关文章

  • 纯CSS写三角形样式集合(原理解析)

    一、实现原理 在css3中,我们主要使用的是一个transparent的属性,意思是透明的,比如我们将字体设置为黑...

  • css 实现三角形箭头

    插入DOM 使用伪类 参考:用纯CSS实现的箭头CSS画三角形原理css整理 -- 右箭头,上下箭头,三角形 这个...

  • web前端入门到实战:css的核心原理分为优先级原则与继承原则两

    css原理:1.优先原则=>后解析的内容会覆盖之前解析的内容(所谓解析就是读取的css样式)2.继承原则=>嵌套里...

  • CSS绘制三角形

    纯CSS绘制三角形,实现原理是将宽高设置为0,设置边框来形成三角形的样式。 首先我们绘制一个宽高为0,边框为30的...

  • 经典面试题:浏览器是怎样解析CSS的?

    摘要: 理解浏览器原理。 原文:浏览器解析 CSS 样式的过程 作者:前端小智 解析 一旦 CSS 被浏览器下载,...

  • CSS基础笔记

    1.引入其他css样式表@import "style.css"引号里填url 1.CSS的工作原理 瀏覽器解析網頁...

  • CSS画三角形原理

    使用纯CSS画三角形,记得去年自己就碰到过。但是当时只是一味的在网上粘贴复制了写代码,并没有深究其原理。今天特地写...

  • css-三角形

    三角形css样式 三角形html结构

  • css实践

    一.纯css创建一个三角形的原理采用的是均分原理,把矩形分为4等份,这4等份其实都是边框 二.css3实现0.5p...

  • 绘制对话框

    Time: 20200131 三角形的绘制 HTML CSS样式 对话框的绘制 HTML CSS样式 显示效果 END.

网友评论

      本文标题:纯CSS写三角形样式集合(原理解析)

      本文链接:https://www.haomeiwen.com/subject/sqzmfqtx.html