我一直在使用Raphael JS(......很棒).我只是想了解如何在我background-imagebackground-size 用Raphael创建的SVG路径中添加和(封面).这是可能吗?
我尝试过的:
我已经尝试添加一个类,但它将它添加到SVG(路径的父),所以我也尝试过 svg path {//background properties, including the image I want to include;}
我也研究过模式,但是我的输出没有我想要的背景属性,因为我不知道如何用模式设置它们(background-image: //;和background-size: //;).
现行守则(拉斐尔)
function myFunction() {
var paper = Raphael("drama", 400,400);
var c = paper.path("M24,48 L313,12L342,174L98,280Z").attr({fill: "url('../imgs/screen.png')", stroke: "none"});
}
Run Code Online (Sandbox Code Playgroud)
目前的拉斐尔输出
<svg height="400" version="1.1" width="400" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="overflow: hidden; position: relative;">
<desc style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Created with Raphaël 2.1.2</desc>
<defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">
<pattern id="1546A235-C4BA-4ED7-A544-C43CE0BA3109" x="0" y="0" patternUnits="userSpaceOnUse" …Run Code Online (Sandbox Code Playgroud) 如果我设置以下内容:
<script type="text/javascript" src="https://test.com/abc"></script>
Run Code Online (Sandbox Code Playgroud)
在 head 标记之间,代码在页面启动时运行。有什么方法可以阻止它在启动期间运行,而是使用 html 按钮的 onclick 方法运行它?