两种纯html+css3实现六边形

 时间:2026-02-14 14:50:56

1、新建html文档。

两种纯html+css3实现六边形

2、书写hmtl代码。

<div class="zcc"></div>

<div class="zcc2">

    <div class="left"></div>

    <div class="right"></div>

</div>

两种纯html+css3实现六边形

3、初始化css代码。

<style>

html, body { width : 100%; height : 100%; margin : 0; padding : 0; }

.wrapper { position : relative; width : 420px; margin : 0 auto; padding : 0; font-size : 0; }

.icon { position : relative; display : inline-block; width : 100px; height : 100px; margin : 20px; border-radius : 18px; -webkit-box-sizing : border-box; -moz-box-sizing : border-box; box-sizing : border-box; }

</style>

两种纯html+css3实现六边形

4、书写css代码。

<style>

.zcc{width: 66px;height: 120px;margin:100px auto;background-color: #008000;position: relative;}

.zcc::before{content:"";width: 0;height: 0;position:absolute;left:-35px;top:0;border-right:35px solid #008000;border-top:60px solid transparent;border-bottom:60px solid transparent;}

.zcc::after{content:"";width: 0;height: 0;position:absolute;right:-35px;top:0;border-left:35px solid #008000;border-top:60px solid transparent;border-bottom:60px solid transparent;}

.zcc2{width: 66px;height: 120px;margin:100px auto;background-color: red;position: relative;}

.zcc2 .left{width: 0;height: 0;position:absolute;left:-35px;top:0;border-right:35px solid red;border-top:60px solid transparent;border-bottom:60px solid transparent;}

.zcc2 .right{width: 0;height: 0;position:absolute;right:-35px;top:0;border-left:35px solid red;border-top:60px solid transparent;border-bottom:60px solid transparent;}

</style>

两种纯html+css3实现六边形

5、代码整体结构。

两种纯html+css3实现六边形

6、查看效果。

两种纯html+css3实现六边形

  • [HTML5应用] CSS3倾斜的网页图片
  • js怎么把DIV的背景图片给取消
  • 手工折纸——旺旺
  • 如何用CSS修改不同input标签的样式
  • 关于html内嵌video的一些参数设置
  • 热门搜索
    什么是闪存卡 幸福来源于什么作文 什么是经济人假设 manager是什么意思 invitation是什么意思 挂科是什么意思 咀嚼是什么意思 ago是什么意思 登鹳雀楼的意思 什么是自由行