SVG icons coloured using js and hash
How do I make an svg icons coloured using js and hash?
Nice technique for colouring svg image. You can append the url of the svg with a hash, and parse location.hash with js to apply a hex value. Icon from SS Standard.. What is a svg icons coloured using js and hash? How do you make a svg icons coloured using js and hash? This script and codes were developed by Niels Oeltjen on 08 September 2022, Thursday.
SVG icons coloured using js and hash - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>SVG icons coloured using js and hash </title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel='stylesheet prefetch' href='https://codepen.io/NielsOeltjen/pen/mWqKev.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<h2>SVG icons coloured using js and hash</h2>
<p> We can append the SVG src with a HEX value. Try changing values in the HTML pane. Broken in some browsers.
</p>
<div class="icons"> <h4>Using <code>iframe</code> tag</h4> <!-- These are the same image. Change the hex value in the url to colour the SVG --> <iframe src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/477/icon.svg#FC237A" width="128" height="96"></iframe> <iframe src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/477/icon.svg#00F2FF" width="128" height="96"></iframe>
</div>
<!--CURRENTLY BROKEN -->
<p><code>embed</code> and <code>object</code> used to work but now not functional. I haven't had a chance to investigate</p>
<div class="icons"> <h4>Using <code>object</code> tag</h4> <!-- These are the same image. Change the hex value in the url to colour the SVG --> <object type="image/svg+xml" data="https://s3-us-west-2.amazonaws.com/s.cdpn.io/477/icon.svg#FC237A"></object> <object type="image/svg+xml" data="https://s3-us-west-2.amazonaws.com/s.cdpn.io/477/icon.svg#00F2FF"></object>
</div>
<div class="icons"> <h4>Using <code>embed</code> tag</h4> <!-- These are the same image. Change the hex value in the url to colour the SVG --> <embed type="image/svg+xml" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/477/icon.svg#FC237A"/> <embed type="image/svg+xml" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/477/icon.svg#00F2FF"/>
</div>
<p> <a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/477/icon.svg" target="_blank">Here's the svg file</a>
</p>
<p> <a href="https://twitter.com/scottjehl/statuses/326453680243097601" target="_blank">How Scott Jehl did it</a>
</p> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
SVG icons coloured using js and hash - Script Codes CSS Codes
object { -moz-border-radius: 4px / 4px; -webkit-border-radius: 4px 4px; border-radius: 4px / 4px;
}
.icons { padding-top: 2em; padding-bottom: 3em;
}
h4 { margin-bottom: 2em;
}
SVG icons coloured using js and hash - Script Codes JS Codes
/* https://twitter.com/scottjehl/statuses/326453680243097601 */
Developer | Niels Oeltjen |
Username | NielsOeltjen |
Uploaded | September 08, 2022 |
Rating | 4.5 |
Size | 2,574 Kb |
Views | 30,360 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Sun | 3,603 Kb |
Nice outline hover effect | 2,237 Kb |
Layout states using jQuery and Data Attributes | 3,078 Kb |
Semantic vertical centering | 2,394 Kb |
Animated background colours | 1,979 Kb |
Prose.io repo icon | 2,162 Kb |
Pretty css spinner | 1,792 Kb |
Emoji selectors | 2,253 Kb |
Button toggle box | 3,043 Kb |
Sweet star loader | 2,228 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Boxes | H3l1um | 2,563 Kb |
TweetBox with React JS | J0zelito | 3,325 Kb |
Awesome textarea | Ayoungh | 1,977 Kb |
LeMandinque | Aadesida | 9,046 Kb |
Flip test | Madhes | 1,635 Kb |
Canvas snow | Win7killer | 2,572 Kb |
Pagepilling.js | Blossk | 6,554 Kb |
React TODO | Enieste | 3,320 Kb |
Nested flexbox layout for library catalog | Boycetrus | 3,271 Kb |
Tile Animation Thing | Frxnz | 4,332 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!