Skip to content

Set solid background for custom svg #283

Closed Answered by codemasher
kaliachka asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, you will need to add a css rule to the <style> section of the svgDefs block, such as svg{background: red;} (note the property name is background or background-color, not fill here) - alternatively you could just add a background-color via stylesheet to the containing html element or the QR Code svg element itself - its css-selector is svg.qrcode by default.

$options->svgDefs = '
	<linearGradient id="gradient" x1="100%" y2="100%">
		<stop stop-color="#D70071" offset="0"/>
		<stop stop-color="#9C4E97" offset="0.5"/>
		<stop stop-color="#0035A9" offset="1"/>
	</linearGradient>

	<style><![CDATA[
		.dark{fill: url(#gradient);}
		.light{fill: red;}
		/* here's the background for the whole…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by kaliachka
Comment options

You must be logged in to vote
1 reply
@codemasher
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants