美文网首页前端面试基础必备
css实现三角形和平形四边形

css实现三角形和平形四边形

作者: puxiaotaoc | 来源:发表于2018-08-17 15:53 被阅读1次

一、三角形

.father {
      width: 0px;
      height: 0px;
      border: 50px solid black;
    }
只设置border
.father {
      width: 0px;
      height: 0px;
      border-top: 50px solid black;
      border-right: 50px solid red;
      border-bottom: 50px solid green;
      border-left: 50px solid blue;
    }
设置四个border
// transparent 关键字表示一个完全透明的颜色,即该颜色看上去将是背景色
.father {
      width: 0px;
      height: 0px;
      border-top: 50px solid black;
      border-right: 50px solid transparent;
      border-bottom: 50px solid transparent;
      border-left: 50px solid transparent;
    }
.caret {
  width: 0;
  height: 0;
  border: 50px solid transparent;
  border-top-color: black;
}
三角形
// 节省空间的三角形
.father {
      width: 0px;
      height: 0px;
      border-top: 50px solid black;
      border-left: 50px solid transparent;
      border-right: 50px solid transparent;
    }
节省空间的三角形
// 等腰梯形
.father {
      width: 50px;
      height: 0px;
      border-top: 50px solid black;
      border-left: 50px solid transparent;
      border-right: 50px solid transparent;
    }
等腰梯形
// 中空的图形
.father {
      width: 50px;
      height: 50px;
      border-top: 50px solid black;
      border-right: 50px solid red;
      border-bottom: 50px solid green;
      border-left: 50px solid blue;
    }
中空的图形
// 平形四边形
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
  <meta charset="utf-8">
  <title></title>
  <style>
    body {
      margin: 0;
      padding: 0;
    }

    .father1 {
      position: relative;
      width: 0;
      height: 0;
      border-top: 50px solid black;
      border-right: 50px solid transparent;
      border-bottom: 50px solid transparent;
      border-left: 50px solid transparent;
    }

    .father2 {
      position: absolute;
      top: -50px;
      left: 50px;
      width: 0;
      height: 0;
      border-top: 50px solid transparent;
      border-right: 50px solid transparent;
      border-bottom: 50px solid green;
      border-left: 50px solid transparent;
    }
  </style>
</head>
<body>
  <div class="father1"></div>
  <div class="father2"></div>
</body>

</html>

平形四边形

参考:https://www.jianshu.com/p/1f32120a503b

相关文章

  • css小技巧

    利用border实现三角形和平行四边形 效果如图: 三角形的实现利用了上面的方法。 效果如图: 效果如图: 效果如图:

  • css实现三角形

    css三角形实现代码

  • 利用css画三角形

    利用css实现三角形 一、首先建立一个四边形 设置其边框属性 二、设置其余边框为透明色 只留下一条边框,用于形成三...

  • css实现三角形和平形四边形

    一、三角形 参考:https://www.jianshu.com/p/1f32120a503b

  • CSS3实现各种图形样式汇总

    本文CSS3实现的图形样式:三角形、水滴、菱形、平行四边形、梯形、便签、五边形、六边形、五角星、对话框、八卦、搜索...

  • 脑筋急转弯,答对6个以上算及格!

    01、从前,三角形,圆形,平行四边形和梯形约好一起出去玩,结果到了约定的那天,圆形,梯形和平行四边形都来了,只有三...

  • css 实现三角形箭头

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

  • 《三角形的面积》教学反思

    三角形面积的知识基础是:三角形底和高的认识以及长方形、正方形和平行四边形面积计算公式。知识的增长点是三角形...

  • 纯CSS制作图形效果

    使用CSS可以制作三角形、圆形、半圆形、平行四边形、扇形以及一些复杂的图形效果。先来看看三角形、圆形、半圆形、扇形...

  • css绘制三角形(border属性的使用)

    1 . 实现一个简单的三角形 使用css 盒模型中的border (边框) 即可实现如下的三角形: 实现原理: 首...

网友评论

    本文标题:css实现三角形和平形四边形

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