[英]How to stretch a fabric canvas to the full width of its parent div
目前的情況我有一個放置在父 div 內的織物畫布。 如何將畫布拉伸到其父級的全寬和全高
這是我的代碼的樣子:
<div class="design_editor_div">
<canvas id="c" width="500" height="500" style="border-style:dashed;border-color:#a1a1a1;text-
align:center;border-width:initial;"></canvas>
<img src="{{ '2.png' | asset_url }}" title="" alt="" style="display: none" id="img">
</div>
您可以使用 css 並選擇 div 的子元素,如下所示:
canvas > div { display: block; width: 100%; height: 100%; }
當然,請使用單獨的樣式表並在頭部包含<link>path-to-stylesheet</link>
或在 html 文檔的頭部包含<style> css... </style>
標簽。 內聯 CSS 樣式應該保留給您需要更改的非常獨特的元素,例如制作 a 或<p>
元素的一部分<strong>
或<u>
。 內聯包含許多<style>
標簽會影響標簽的可讀性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.