[英]How to set the width and height of a Raphael JS rectangle based on the lines of text it contains?
[英]How to set the width and height of a Raphael JS paper same as those of its containing div?
我的Raphael JS論文是在id為“ temp”的div中創建的。 我希望紙張的高度和寬度與div temp的高度和寬度相同。 如何使用javascript或jquery執行此操作?
的HTML
<div id="temp" style="border:1px solid red;width:500px;height:500px"></div>
我嘗試使用獲取高度和寬度
document.getElementById("temp").style.width
document.getElementById("temp").style.height
但是當我用它來創建紙張時,我收到了JS警告。
如果您的JavaScript中包含以下RaphaelJS初始化:
var paper = new Raphael('myDiv');
在html中:
<div id="myDiv" style="width: 200px; height: 200px;" />
在這里,拉斐爾紙將是200px x 200px。 它會自動執行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.