• 使用CSS样式,制作六边形



     



              在制作网上中,经常会遇到绘制其它不规则的图形,如六边形,八边形这类的,在复杂的图形,也是由我们的基本图形组成了,如上面的六边形,就是由两个三角形,一个矩形组成。 
       先看看,如何绘制三角形 ,与四边形。         三角形: 
                          <div class="triangle"></div> 
                          .triangle{ 
                                0px;   
                              height: 0px;   
                             border- 80px; 
                              border-color:transparent transparent green; 
                              border-style: solid; 
                          } 
             注: 将宽与高设置为0,设置边框的宽度,及样式的样式,最后将上,左,右边的边框,设置成透明色,这样我们就可以得到想到的三角形。 
            如图:   

                四边形: 
                          与三角形设置类似,不同的是,需要设置div的宽度,我们需要一个小的四边形与一个大的四边形,改变宽度的大小即可: 
                            <div class="fourangle"></div> 
                            <div class="fourangle2"></div>           
                             .fourangle{ 
                                         70px;   
                                       height: 0px;   
                                       border- 80px; 
                                        border-color:transparent transparent green; 
                                        border-style: solid; 
                                } 
                                .fourangle2{ 
                                         100px;   
                                       height: 0px;   
                                       border- 80px; 
                                        border-color:transparent transparent green; 
                                        border-style: solid; 
                                } 
                   效果如图: 
                         




         完整六边形代码如下: 
    <!DOCTYPE html> 
    <html> 
    <head lang="en"> 
        <meta charset="UTF-8"> 
        <title></title> 
        <style type="text/css"> 
            #shape{ 
                margin: 200px 0px 0px 200px; 
                position: relative; 
                 300px; 
                height: 500px; 
                /*border: 1px solid red;*/ 

              overflow: hidden; 
              background-image: url("img/bg/bg1.png"); 
                background-position: center; 
            } 
            #div1{ 
                position: absolute; 
                top:-150px; 
                 0px; 
                height: 0px; 
                border- 150px;  
     
              border-color:white white transparent; 
              border-style: solid; 

            } 
            #rect{ 
                /*border: 1px solid green;*/ 
                position: absolute; 
                top:150px; 
                 300px; 
                height: 200px; 

            } 
            #div2{ 
                position: absolute; 
                top:350px; 
                 0px; 
                height: 0px; 
                border- 150px; 

               border-color:transparent white; 
               border-style: solid; 

            } 
        </style> 
    </head> 
    <body> 
       <div id="shape"> 
           <div id="div1"></div> 
           <div id="rect"></div> 
           <div id="div2"></div> 
       </div> 
    </body> 
    </html>

  • 相关阅读:
    jupyter notebook 和 opencv
    AMD 处理器 Ubuntu 16.04 LTS 配置 opencv、caffe 小结
    caffe 在 windows 使用
    MATLAB数字图像处理
    游记(5)
    POJ-1789-Truck History 解题报告
    POJ-2560-Freckles 解题报告
    POJ-1308-Is It A Tree? 解题报告
    POJ-1182-食物链 解题报告
    POJ-1861-Network 解题报告
  • 原文地址:https://www.cnblogs.com/doubolexiang/p/7222423.html
Copyright © 2020-2023  润新知