我想使用SVG在整個頁面上製作波浪線,並且它應該是響應式的,無論屏幕寬度如何,都可以跨頁面伸展。如何創建響應SVG圖像
我在這個StackOverflow文章中看到了我想要的那種東西,但是SVG只產生一個固定寬度的圖像。
<svg height="125" width="1349">
<path d="M -35 100 s 35 50 75 0" stroke="rgb(255, 195, 56)" stroke- width="5" fill="none" />
<path d="M 40 100 s 75 -125 150 0" stroke="rgb(255, 195, 56)" stroke-width="5" fill="rgb(255, 195, 56)" />
<path d="M 190 100 s 35 50 75 0" stroke="rgb(255, 195, 56)" stroke-width="5" fill="none" />
<path d="M 265 100 s 75 -125 150 0" stroke="rgb(255, 195, 56)" stroke-width="5" fill="rgb(255, 195, 56)" />
<path d="M 415 100 s 35 50 75 0" stroke="rgb(255, 195, 56)" stroke-width="5" fill="none" />
<path d="M 490 100 s 75 -125 150 0" stroke="rgb(255, 195, 56)" stroke-width="5" fill="rgb(255, 195, 56)" />
<path d="M 640 100 s 35 50 75 0" stroke="rgb(255, 195, 56)" stroke-width="5" fill="none" />
<path d="M 715 100 s 75 -125 150 0" stroke="rgb(255, 195, 56)" stroke-width="5" fill="rgb(255, 195, 56)" />
<path d="M 865 100 s 35 50 75 0" stroke="rgb(255, 195, 56)" stroke-width="5" fill="none" />
<path d="M 940 100 s 75 -125 150 0" stroke="rgb(255, 195, 56)" stroke-width="5" fill="rgb(255, 195, 56)" />
<path d="M 1090 100 s 35 50 75 0" stroke="rgb(255, 195, 56)" stroke-width="5" fill="none" />
<path d="M 1165 100 s 75 -125 150 0" stroke="rgb(255, 195, 56)" stroke-width="5" fill="rgb(255, 195, 56)" />
<path d="M 1315 100 s 35 50 75 0" stroke="rgb(255, 195, 56)" stroke-width="5" fill="none" />
Sorry, your browser does not support inline SVG.
</svg>
一個可能的解決方案是使用javascript在整個頁面寬度上重複使用SVG。或者我想我可以將許多圖像鏈接在一起,並使用媒體查詢隱藏/顯示足以填充頁面寬度,但這似乎是一個笨拙的解決方案。
有誰知道純SVG/HTML5解決方案?
刪除'height =「125」width =「1349」' –
https://tympanus.net/codrops/2014/08/19/making-svgs-responsive-with-css/ –