Currently, I am undertaking a small project that involves creating a box with rough edges around some text. To achieve this effect, I am utilizing an SVG with unique edges similar to the design found at this link: (except mine is in SVG format).
My goal is to use this SVG as a background for a DIV element and have it seamlessly extend to the edges of the containing DIV, giving the appearance of a non-square shape regardless of screen size adjustments.
Unfortunately, my current method is not producing the desired outcome. This is what we are currently using:
background-image: url(above.svg);
background-size: cover;
This approach falls short because only half of the edges appear rough, while the others extend beyond the visible area.
We also attempted:
background-size: 100% 100%;
However, this resulted in the image maintaining its original dimensions.
I am now uncertain about the best solution using JS/CSS to address this issue.
Here are two potential options I am considering:
OPTION 1: write JS code that:
a. monitors changes in DIV size
b. adjusts width and height of SVG accordingly
c. sets background image as 100% 100%.
OPTION 2:
a. insert image as a typical image within DIV
b. set DIV as position relative and IMAGE as position absolute
c. specify top/bottom/left/right values as ZERO for the image. (Currently not working due to SVG format - reason unknown).
I lean towards option 2 as the more favorable choice, but I remain open to other possibilities...
Any assistance on this matter would be greatly appreciated.
UPDATE: A functioning example can be accessed here: https://jsfiddle.net/sunnsideup/er1xd0wg/15/