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!
Name | Size |
Pt versus px | 2,254 Kb |
-ms-high-contrast media feature | 1,792 Kb |
Semi-transparent SVG with transparent background and WHCM | 1,999 Kb |
Border-radius causes weird form control rendering | 2,233 Kb |
-ms-high-contrast and -ms-high-contrast-adjust | 1,978 Kb |
Pixel sizes for physical rendering test | 2,122 Kb |
VoiceOver bug with SVG img elements | 1,467 Kb |
A Pen by Patrick H. Lauke | 1,495 Kb |
Basic fluid typography with vw and issues with full-page zoom - completely broken example | 2,339 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 |
C.Rowe Button | Brownerd | 2,473 Kb |
Full page table inside the grid | Twikito | 1,864 Kb |
Find The Penguin | Lelder | 2,212 Kb |
A Pen by Adrien Clerbois | AClerbois | 6,501 Kb |
Whyutils | LeYvan | 3,752 Kb |
Loading animation | Codeams | 2,408 Kb |
3D-box | Parthviroja | 2,346 Kb |
Css or Czz.. | Judag | 4,111 Kb |
Acorrdian 2016 | Milanodituti | 3,720 Kb |
Svg penguin | _massimo | 2,990 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!