Semi-transparent SVG with transparent background - using SVG with stroke set to currentColor and opacity dependent on high-contrast mode
- Semi-transparent SVG with transparent background - using SVG with stroke set to currentColor and opacity dependent on high-contrast mode Previews
- Semi-transparent SVG with transparent background - using SVG with stroke set to currentColor and opacity dependent on high-contrast mode HTML Codes
- Semi-transparent SVG with transparent background - using SVG with stroke set to currentColor and opacity dependent on high-contrast mode CSS Codes
How do I make an semi-transparent svg with transparent background - using svg with stroke set to currentcolor and opacity dependent on high-contrast mode?
What is a semi-transparent svg with transparent background - using svg with stroke set to currentcolor and opacity dependent on high-contrast mode? How do you make a semi-transparent svg with transparent background - using svg with stroke set to currentcolor and opacity dependent on high-contrast mode? This script and codes were developed by Patrick H. Lauke on 25 September 2022, Sunday.
Semi-transparent SVG with transparent background - using SVG with stroke set to currentColor and opacity dependent on high-contrast mode - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Semi-transparent SVG with transparent background - using SVG with stroke set to currentColor and opacity dependent on high-contrast mode</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h1>Semi-transparent SVG with transparent background - using SVG with stroke set to currentColor and opacity dependent on high-contrast mode</h1>
<p>Three ways of showing an SVG. Do any of these show up in Windows High Contrast Mode in IE11/Edge/others? The SVG contains its own <code>style</code> block, and instead of an explicit color value it defines <code>stroke: currentColor</code> which inherits it from the current context's foreground color. This colour is automatically changed when switching into Windows High Contrast Mode, meaning that this SVG will adapt correctly to whatever color/contrast mode (including custom modes) the user has set. In addition, the icon is set to <code>opacity: 0.5</code>, but is changed to <code>opacity: 1</code> if <code>-ms-high-contrast: active</code>.</p>
<p>Note that in Firefox, you need to hard refresh (SHIFT+refresh) after changing into/out of WHCM, as the <code>currentColor</code> seems to be cached somehow persistently even when refreshing. Also, <code>opacity</code> doesn't seem to apply to SVG-based CSS backgrounds.</p>
<h2>Image</h2>
<img src="data:image/svg+xml,%3Csvg%20viewBox%3D%270%200%2032%2032%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%3E%3Cstyle%3Epath%7Bstroke%3AcurrentColor%3Bopacity%3A0.5%3Bstroke-width%3A%202%3Bstroke-linecap%3Around%3Bstroke-miterlimit%3A10%3B%7D%20%40media%20all%20and%20%28-ms-high-contrast%3Aactive%29%7Bpath%7Bopacity%3A1%3B%7D%7D%3C%2Fstyle%3E%3Cpath%20d%3D%27M4%208h24M4%2016h24M4%2024h24%27%2F%3E%3C%2Fsvg%3E" width="25" height="25" alt="">
<h2>CSS-generated content</h2>
<div id="svg-foreground"><span></span></div>
<h2>CSS background</h2>
<div id="svg-background"><span></span></div>
</body>
</html>
Semi-transparent SVG with transparent background - using SVG with stroke set to currentColor and opacity dependent on high-contrast mode - Script Codes CSS Codes
#svg-foreground { width: 25px; height: 25px; }
#svg-foreground span::before { content: url("data:image/svg+xml,%3Csvg%20viewBox%3D%270%200%2032%2032%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%3E%3Cstyle%3Epath%7Bstroke%3AcurrentColor%3Bopacity%3A0.5%3Bstroke-width%3A%202%3Bstroke-linecap%3Around%3Bstroke-miterlimit%3A10%3B%7D%20%40media%20all%20and%20%28-ms-high-contrast%3Aactive%29%7Bpath%7Bopacity%3A1%3B%7D%7D%3C%2Fstyle%3E%3Cpath%20d%3D%27M4%208h24M4%2016h24M4%2024h24%27%2F%3E%3C%2Fsvg%3E");
}
#svg-background { width: 25px; height: 25px; background: url("data:image/svg+xml,%3Csvg%20viewBox%3D%270%200%2032%2032%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%3E%3Cstyle%3Epath%7Bstroke%3AcurrentColor%3Bopacity%3A0.5%3Bstroke-width%3A%202%3Bstroke-linecap%3Around%3Bstroke-miterlimit%3A10%3B%7D%20%40media%20all%20and%20%28-ms-high-contrast%3Aactive%29%7Bpath%7Bopacity%3A1%3B%7D%7D%3C%2Fstyle%3E%3Cpath%20d%3D%27M4%208h24M4%2016h24M4%2024h24%27%2F%3E%3C%2Fsvg%3E"); }
Developer | Patrick H. Lauke |
Username | patrickhlauke |
Uploaded | September 25, 2022 |
Rating | 3 |
Size | 2,510 Kb |
Views | 26,312 |
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!
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 |
JS Countdown Timer | Ayoungh | 2,435 Kb |
03 - CSS Variables | Run-time | 2,682 Kb |
Canvas stripes | Adrianparr | 1,948 Kb |
Apex Calculator | Michaelwnelson | 2,370 Kb |
NgEasyModal | Lorenzodianni | 4,159 Kb |
Css3 loader | Clknap | 2,391 Kb |
SVG Icons Template | Legofsalmon | 2,618 Kb |
Heartbeat | Apetrov | 2,079 Kb |
Header | Er40 | 1,542 Kb |
404 Error Page | WebSonick | 3,203 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!