CSS3六角形代码

作者: 子瑜说IT | 来源:发表于2019-05-16 22:27 被阅读28次

分享一段代码实例,它实现了六角形效果。

代码实例如下:

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<meta name="author" content="[网页链接](http://www.softwhy.com/%22) />

<title>蚂蚁部落</title>

<style type="text/css">

#six {

  width: 0;

  height: 0;

  border-left: 60px solid transparent;

  border-right: 60px solid transparent;

  border-bottom: 120px solid red;

  position: relative;

}

#six:after {

  content: "";

  width: 0;

  height: 0;

  border-left: 60px solid transparent;

  border-right: 60px solid transparent;

  border-top: 120px solid red;

  position: absolute;

  top: 40px;

  left: -60px;

}

.six {

  position: absolute;

  top: 50%;

  left: 50%;

  transform: translate(-50%,-50%);

}

</style>

</head>

<body>

  <div class="six">

    <div id="six"></div>

  </div>

</body>

</html>

最后,给大家推荐一个前端学习进阶内推交流群685910553前端资料分享),不管你在地球哪个方位,
不管你参加工作几年都欢迎你的入驻!(群内会定期免费提供一些群主收藏的免费学习书籍资料以及整理好的面试题和答案文档!)

如果您对这个文章有任何异议,那么请在文章评论处写上你的评论。

如果您觉得这个文章有意思,那么请分享并转发,或者也可以关注一下表示您对我们文章的认可与鼓励。

愿大家都能在编程这条路,越走越远。

相关文章

网友评论

    本文标题:CSS3六角形代码

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