SVG 例子

这只是一个入门的实力,但无不展示了SVG足够的强大。如果再配合其他的技术,诸如javascript等,可以想象很多超难的图形都能在网页上展现出来。

 

Step1. //HTML5.svg

 

<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="400" height="200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

<desc>Reusing items</desc>
  <defs>
     <polygon id="lens" points="65,50 185,50 185,75, 150,100 100,100 65,75" fill="none" stroke="purple" stroke-width="4"/>
     <radialGradient id="irisGradient">
        <stop offset="25%" stop-color="green" />
        <stop offset="100%" stop-color="dodgerblue" />
     </radialGradient>
     <g id="eye">
        <ellipse cy="50" rx="50" ry="25" fill="none" stroke="black"/>
        <circle cy="50" r="25"/>
        <circle cy="50" r="10" fill="black"/>
     </g>
  </defs>
  <g>
    <use xlink:href="#eye" x="125" fill="url(#irisGradient)"/>
    <use xlink:href="#eye" x="250" fill="dodgerblue"/>     
    <use xlink:href="#lens"/>
    <use xlink:href="#lens" x="125"/>
    <line x1="65" y1="50" x2="310" y2="50" stroke="plum" stroke-width="2"/>           
  </g>
</svg>

 

Step2. //HTM5.jsp

 

<html>
<head>
<title>Hello World!</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
</head>
<body bgcolor="#FFFFFF">
<!-- 下一句嵌入SVG内容 -->
<embed src="HTML5.svg"> 
</body>
</html>

 

Step3.  //http://127.0.0.1:8080/HTML5.jsp

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值