在Opera中使用SVG的正确方法是什么? [英] What's the correct way to use SVG in Opera?

查看:109
本文介绍了在Opera中使用SVG的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我如何强制Opera歌剧在html中渲染SVG?

 < svg xmlns =http://www.w3.org/2000/svg版本=1.1宽度=142height =142> 
rect x =19y =19width =104height =104r =0rx =0ry =0fill =nonestroke = #000000
style =stroke-opacity:1; stroke-width:2; stroke-opacity =1stroke-width =2/>
rect x =36y =36width =70height =70r =0rx =0ry =0fill =nonestroke = #000000
style =stroke-opacity:1; stroke-width:2; stroke-opacity =1stroke-width =2/>
< / svg>

如果文件扩展名不是.html,则此代码正常工作



upd:
我试图在新窗口中将div与由raphael.js生成的svg放在一起。并且它在Opera中不起作用。为了让HTML中的SVG能够正常工作,浏览器必须有一个HTML5解析器,并且Opera将会拥有这个解析器。

一个只有从版本12开始。



如果您绝对必须在HTML代码中使用SVG,您需要将文档的xhtml文件扩展名设置为有效的xml文件(如果您是从光盘运行它),并且它也必须在从Web服务器发送时使用 application / xhtml + xml mime类型或另一个有效的xml MIME类型。


Can anyone tell me how to force Opera opera to render SVG in html?

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="142" height="142">
    <rect x="19" y="19" width="104" height="104" r="0" rx="0" ry="0" fill="none" stroke="#000000"
          style="stroke-opacity: 1; stroke-width: 2;" stroke-opacity="1" stroke-width="2"/>
    <rect x="36" y="36" width="70" height="70" r="0" rx="0" ry="0" fill="none" stroke="#000000"
          style="stroke-opacity: 1; stroke-width: 2;" stroke-opacity="1" stroke-width="2"/>
</svg>

This code works fine if file extension is not .html

upd: I'm trying to put div with svg inside generated by raphael.js in new window. And it doesnt work in Opera.

解决方案

To have SVG in HTML working, the browser must have an HTML5 parser and Opera will have one only since version 12.

If you absolutely have to have SVG right in the HTML code, you need your document to have an xhtml file extension an be a valid xml file (if you are running it from disc), and it also has to be served with application/xhtml+xml mime type or another valid xml mime type when sent from a web server.

这篇关于在Opera中使用SVG的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆