• css+html如何绘制三角形


    html+css如何绘制三角形

    html代码:
    
    <!doctype html> 
    <html lang="en"> 
    <head> 
        <meta charset="utf-8"> 
        <title>CSS Triangle Demo</title> 
        <link rel="stylesheet" href="triangle.css"> 
    </head> 
    
    <body> 
        <h3>Down Triangle</h3> 
        <div class="down-triangle"> 
        </div> 
     
        <h3>Up Triangle</h3> 
        <div class="up-triangle"> 
        </div> 
     
        <h3>Left Triangle</h3> 
        <div class="left-triangle"> 
        </div>     
     
        <h3>Right Triangle</h3> 
        <div class="right-triangle"> 
        </div>         
     </body> 
    </html> 
    
    
    css代码:
    .down-triangle { 
    	 0; 
    	height: 0; 
    	border- 10px 10px 0 10px; 
    	border-style: solid; 
    	border-color: #dc291e transparent; 
    } 
    
    .up-triangle { 
     0; 
    height: 0; 
    border- 0px 10px 10px 10px; 
    border-style: solid; 
    border-color: #dc291e transparent; 
    } 
    
    .left-triangle { 
     0; 
    height: 0; 
    border- 10px 10px 10px 0px; 
    border-style: solid; 
    border-color: transparent #dc291e; 
    } 
    
    .right-triangle { 
     0; 
    height: 0; 
    border- 10px 0px 10px 10px; 
    border-style: solid; 
    border-color: transparent #dc291e; 
    }
    

    HTML5 Canvas

    在你的HTML文件中有以下的canvas元素:
    
    <canvas id="triangle" height="100" width="100">Triangle</canvas>
    这里的如何使用JavaScript绘制一个三角形:
    
    var canvas = document.getElementById('triangle');
    var context = canvas.getContext('2d');
    
    context.beginPath();
    context.moveTo(0, 0);
    context.lineTo(100, 0);
    context.lineTo(50, 100);
    
    context.closePath();
    
    context.fillStyle = "rgb(78, 193, 243)";
    context.fill();
    

    SVG (Scalable Vector Graphics)
    
    这是如何在您的标签,你可以定义一个内联SVG三角形:
    
    <svg xmlns="http://www.w3.org/2000/svg" version="1.1" class="svg-triangle">
      <polygon points="0,0 100,0 50,100"/>
    </svg>
    然后,只需添加一些样式:
    
    .svg-triangle{
    	margin: 0 auto;
    	 100px;
    	height: 100px;		
    }		
    
    .svg-triangle polygon {
    	fill:#98d02e;
    	stroke:#65b81d;
    	stroke-2;
    }
  • 相关阅读:
    不用写代码的框架
    bat执行python脚本,执行多条命令
    VMware-workstation-full-15.1.0-13591040安装破解-附件密钥
    w10谷歌chrome关闭自动更新
    谷歌安装提示已经安装高版本解决
    python项目三方库导出导入 requirements.txt文件
    点阴影
    goto gamedev blog
    20135315-信息安全系统设计基础第五周学习总结
    win10 +python3.6环境下安装opencv以及pycharm导入cv2有问题的解决办法
  • 原文地址:https://www.cnblogs.com/xiuxiu123/p/5391194.html
Copyright © 2020-2023  润新知