How to affect other elements if SVG is hovered over? - html

I have this issue here where I have an svg as a logo next to my .brand-name class. What I have done so far is to make sure the svg looks like it's a part of the .brand-name class, meaning that whenever I hover over the .brand-name class, the svg also appears as if it was hovered over. However, I could not find any material as to how to get the opposite effect; meaning that when I hover over the svg, the .brand-name class also appears like it's been hovered over. I have been researching this topic using this thread, but I couldn't come up with a solution that could fit the svg to .brand-name class issue.
HTML
<ul class="brand">
<li><a href="#" class="logo-container">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" width="40px" height="35px" viewBox="0 0 363.818 363.818" style="enable-background:new 0 0 363.818 363.818;" xml:space="preserve">
<path class="logo" d="M358.872,0.841c-3.196-1.538-7.014-0.931-9.572,1.526c-19.515,18.728-53.141,46.415-102.511,71.961 c-2.159,1.118-3.737,3.106-4.333,5.463c-4.028,15.908-11.933,33.271-23.492,51.607l-4.705,7.462l8.772-38.205 c0.715-3.115-0.378-6.368-2.828-8.42c-2.451-2.052-5.846-2.556-8.786-1.303l-1.015,0.428 C110.79,133.291,81.352,198.24,72.67,233.22c-3.013,12.141-4.516,24.163-4.465,35.738c0.02,4.466,0.272,8.722,0.75,12.705 l-66.39,67.703c-3.211,3.273-3.246,8.505-0.078,11.822c1.667,1.745,3.904,2.629,6.149,2.629c2.02,0,4.045-0.717,5.664-2.164 l182.428-163.851c0.896,0.059-103.874,109.806-102.925,109.806c14.22,0,33.863-6.555,56.804-18.95 c30.935-16.717,65.508-42.37,99.979-74.185c2.832-2.612,3.551-6.805,1.753-10.213c-1.798-3.407-5.662-5.181-9.42-4.315 l-21.363,4.904l7.465-4.706c20.835-13.136,40.313-21.511,57.891-24.897c1.901-0.367,3.622-1.372,4.875-2.849 c41.348-48.75,58.853-96.919,66.256-128.743c2.69-11.567,4.579-23.134,5.607-34.38C363.972,5.742,362.069,2.379,358.872,0.841z" fill="#FFFFFF"/>
</svg>
</a></li>
<li>Company Name</li>
</ul>
CSS
.header ul.brand .logo {
transition: 0.2s ease-in-out fill;
}
.header ul.brand:hover .logo {
fill: #fbabab;
color: #fbabab;
}
.header ul.brand .logo:hover {
fill: #fbabab;
color: #fbabab;
}
I've already created the motion where the svg appears to be hovered over when the user hovers over the .brand-name anchor class.
Additionally, if more information is required to aid me on this issue, I'd be more than grateful to help out to provide such. Please comment down below if such clarification is necessary. Many thanks!

You can add hover to both at the same time:
.header ul.brand:hover .logo,
.header ul.brand:hover .brand-name {
fill: #fbabab;
color: #fbabab;
}
Or
.header ul.brand:hover .logo {
fill: #fbabab;
}
.header ul.brand:hover .brand-name {
color: #fbabab;
}
However, I would simplify the HTML to:
<header>
<a href="#">
<svg>...</svg>
<span>Company Name</span>
</a>
</header>
And use this as an example:
header a:hover svg {
...
}
header a:hover span {
...
}

Related

Justify the text inside a grid

I'm trying to justify my text inside a grid on cargo collective. Till now I couldn't do that and I had to export a svg for each title and place it as an image (like in this page: https://gracegloriadenis.com/IN-FROM-AND-WITH)
But right now the text would be afftected by a dark mode toggle and a svg won't be affected at all so I'll have to find a solution to justify the text in the div (as in "In, From and With" the title of the page I've just shared with you)
This is my code:
<div grid-col="x12" grid-pad="0" class=""><h1>CIVITONIA</h1>
Civitonia is the title that should be justified and it should touch both sides of the div always. Doing that I'd like not to have a size for the text (ex: font size:45rem;) but to have the text as big as the container. Is it possible?
Doing that it would be a lot easier even to have a responsive version of it, as the box would be smaller in the mobile and the text would follow it.
This is the script I'm using for the dark mode:
the script
<button onclick="myFunction()">Dark Mode</button>
<script>
function myFunction() {
var element = document.body;
element.classList.toggle("dark-mode");
}
</script>
CSS related to it:
.dark-mode {
background-color: black!important;
color: #d9ff76!important;
}
.dark-mode button {
color: black!important;
background-color: #d9ff76;
padding: 5px 5px 5px 5px;
border-radius: 15px;
border: solid 1px #000000;
cursor: pointer;
position: absolute;
bottom: 10px;
}
Best you're going to get with just CSS (which is pretty close) is using clamp for font size, use like:
font-size: clamp(<min value>, <preferred value>, <max value>);
Then you set "min value" to 0px and set "max value" to 1000px (a value that will never be reached). The preferred value will need some tweaking based on the font family used and the amount of characters -- so you will have to do it on a per instance basis. I've set the below example up using CSS custom properties (variables) to make it a bit easier, all you have to do is set --clampFontSize: <prefered-value> on an element (preferably in vw units (viewport width))
body { line-height: 1; margin: 0 } h1 { margin: 0 }
.clampText h1 {
font-size: clamp(0px, var(--clampFontSize, 1vw), 1000px);
text-align: center
}
<div class="clampText" style="--clampFontSize: 17.5vw">
<h1>CIVITONIA</h1>
</div>
<div class="clampText" style="--clampFontSize: 12vw">
<h1>In, from, <em>and</em> with</h1>
</div>
Otherwise, if you put your SVG inline then you can control the color on the fly with CSS — the example will have a dark gradient background and white svg color if dark mode is on. Else it will have a light gradient background and black svg color if dark more is off
Note each <path> is set to fill: currentColor in the CSS, this is to inherit the path fill color from the parent <svg> which is inheriting the color from #colorOuterSVG — sometimes paths shouldn’t be filled though and instead have a stroke, or sometimes it’s a circle or something else. So the CSS may need to be adapted to your needs.
The gradients and button color are setup using CSS Custom Properties (variables)
:root {
--gradient1: #fca5a5, #fcd34d, #bef264, #6ee7b7, #67e8f9; /* Body */
--gradient2: #f0abfc, #c4b5fd, #93c5fd, #67e8f9, #6ee7b7; /* SVG Container */
--color: black; --contrast: white;
--darkOn: none; --darkOff: block;
}
:root.dark-mode {
--gradient1: #991b1b, #92400e, #3f6212, #065f46, #155e75; /* Body */
--gradient2: #86198f, #5b21b6, #1e40af, #155e75, #065f46; /* SVG Container */
--color: white; --contrast: black;
--darkOn: block; --darkOff: none;
}
body { background: linear-gradient(60deg, var(--gradient1)) no-repeat }
.darkModeOn { display: var(--darkOn) }
.darkModeOff { display: var(--darkOff) }
button {
background-color: var(--contrast);
border: 1px solid currentColor;
border-radius: 0.375em;
color: var(--color);
cursor: pointer;
display: inline-flex;
align-items: center;
margin-bottom: 8px;
padding: .5em 1em;
}
button span { margin-right: .25em }
.colorOuterSVG {
background: linear-gradient(60deg, var(--gradient2)) no-repeat;
border: 1px solid currentColor;
border-radius: 0.375em;
color: var(--color);
padding: 0.5em
}
.colorSVG { display: block }
.colorSVG path { fill: currentColor }
<button onclick="document.documentElement.classList.toggle('dark-mode')"><span class="darkModeOn">Disable</span><span class="darkModeOff">Enable</span>Dark Mode</button>
<div class="colorOuterSVG">
<svg class="colorSVG" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 1920 239.3" style="enable-background:new 0 0 1920 239.3;" xml:space="preserve">
<g>
<path d="M20.5,165.3V41.5c0-9.6-6.3-14.4-19-14.4c-1,0-1.5-1.6-1.5-4.8c0-3.2,0.5-4.8,1.5-4.8c3,0.4,11.9,0.6,26.6,0.6 s23.5-0.2,26.6-0.6c0.8,0,1.3,1.6,1.3,4.8c0,3.2-0.4,4.8-1.3,4.8c-7,0-11.8,1-14.3,3.1c-2.5,2.1-3.8,5.9-3.8,11.3v123.8 c0,9.8,6,14.7,18.1,14.7c0.8,0,1.3,1.6,1.3,4.8c0,3.2-0.4,4.8-1.3,4.8c-5.8-0.6-14.5-0.9-26.1-0.9c-11.6,0-20.3,0.3-26.1,0.9 c-0.8,0-1.3-1.6-1.3-4.8c0-3.2,0.4-4.8,1.3-4.8C14.5,180,20.5,175.1,20.5,165.3z"/>
<path d="M87.6,165.3v-116c0-8.5-1.5-14.3-4.6-17.5c-3.1-3.2-7.8-4.8-14.4-4.8c-0.8,0-1.3-1.6-1.3-4.8c0-3.2,0.4-4.8,1.3-4.8 c2.9,0.4,7.9,0.6,14.9,0.6c7,0,11.6,0.3,13.8,0.9c2.2,0.6,4.1,2.4,5.9,5.2L179.6,147c0.7,1.1,1.5,1.6,2.4,1.6 c1.5,0,2.3-1.4,2.3-4.1V41.7c0-9.7-5.7-14.6-17.2-14.6c-0.9,0-1.4-1.6-1.4-4.8c0-3.2,0.5-4.8,1.4-4.8c3.1,0.4,9.4,0.6,18.9,0.6 c9.5,0,15.8-0.2,18.8-0.6c0.9,0,1.4,1.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 s0.5-4.7,1.4-4.8C457.7,180,463.7,175.1,463.7,165.3z M479.8,100.2c0,2.6,1.3,4.2,3.8,4.9c2.5,0.7,6.1,1,10.8,1 c25.9,0,38.8-13.6,38.8-40.9c0-11-3.5-20.2-10.5-27.8c-7-7.6-16.7-11.4-29.1-11.4h-9c-3.1,0-4.6,1.3-4.6,3.9V100.2z"/>
<path d="M586.8,104.9c0-22,5.9-42.5,17.6-61.6c11.8-19,27.6-28.6,47.5-28.6c17.8,0,33,8.7,45.6,26.1c12.6,17.4,18.9,38.9,18.9,64.5 c0,21.4-5.8,41.2-17.5,59.4c-11.6,18.2-27.5,27.2-47.6,27.2c-19.4,0-35.1-8.6-46.9-25.7C592.7,149.2,586.8,128.7,586.8,104.9z M606,97.5c0,26,5,46.6,15,62c10,15.4,20.6,23.1,31.8,23.1c14.2,0,25.2-7.2,33-21.7c7.7-14.5,11.6-32.3,11.6-53.5 c0-23.4-4.9-43.2-14.6-59.4c-9.8-16.2-20.4-24.4-32.1-24.4c-14.1,0-25,7.6-32.9,22.7C609.9,61.6,606,78.6,606,97.5z"/>
<path d="M747.1,165.3l6-118.5c0.4-9-2.4-15-8.4-17.8c-2.7-1.3-6.2-1.9-10.7-1.9c-0.9,0-1.4-1.6-1.4-4.8c0-3.2,0.5-4.8,1.4-4.8 c3,0.4,8,0.6,15,0.6c7,0,11.6,0.6,13.7,1.9c2.1,1.3,3.8,3.7,5.1,7.2l47.5,126.6c0.8,2.3,1.5,3.4,2.1,3.4c0.7,0,1.5-1.2,2.4-3.6 l48.7-127.1c1.4-3.8,3.3-6.2,5.6-7.1c2.3-0.9,6.7-1.3,13.3-1.3c6.6,0,11.4-0.2,14.6-0.6c0.9,0,1.4,1.6,1.4,4.8 c0,3.2-0.5,4.8-1.4,4.8c-8.6,0-14.2,2.9-16.8,8.8c-1.4,3.4-2.1,8.1-2,13.9l0.6,115.5c0.1,9.8,5.4,14.7,15.9,14.7 c1,0,1.5,1.6,1.5,4.8c0,3.2-0.5,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9,26.6-29.4,39.9-40.6,39.9c-4,0-7.1-2-9.2-6c-2.1-4-3.2-9-3.2-15.1 c0-17.7,5.8-36.8,17.5-57.4c11.6-20.6,23.9-30.9,36.9-30.9c4.9,0,9.3,2.3,13.4,7l2.4-8.8c0.5-2,2.7-3,6.7-3c3.9,0,5.7,1,5.1,3 L1087.5,163.2z M1084.9,120.5l4.5-19c-2.8-7-7.2-10.5-13.2-10.5c-9,0-17.4,9.2-25.2,27.6c-7.7,18.4-11.6,34.4-11.6,48 c0,7.9,2,11.8,5.9,11.8c3.7,0,8.9-4.2,15.6-12.6c6.7-8.4,11.9-16.2,15.7-23.4C1080.4,135.2,1083.1,127.9,1084.9,120.5z"/>
<path d="M1188.1,163.2c-0.7,2.8-1,5.4-1,7.8c0,3.3,1.1,4.9,3.5,4.9c2.3,0,6.5-3.9,12.5-11.7c0.2-0.3,0.4-0.4,0.6-0.4 c0.8,0,1.7,0.5,2.4,1.6c0.8,1.1,1.2,1.9,1.2,2.5c0,0.6-0.1,1-0.3,1.1c-10.7,15.3-20.3,23-28.6,23c-3.7,0-5.5-3.5-5.5-10.5 c0-3.3,0.3-6.6,1-10l12.6-55.9c2-8.9,3-14.9,3-18.2c0-3.8-1-5.7-3-5.7c-5.7,0-13.9,9.7-24.5,29c-10.6,19.3-20,41.9-28.3,67.7 c-0.7,2.4-3,3.6-7,3.6c-4,0-5.7-1.4-5.1-4.1l17.7-77.7c0.4-1.8,0.6-3.4,0.6-4.9c0-3.9-1.1-5.9-3.2-5.9c-2.1,0-5.7,3.6-10.7,10.8 c-0.3,0.3-0.5,0.4-0.8,0.4c-0.8,0-1.6-0.5-2.4-1.6c-0.8-1-1.3-1.9-1.3-2.7c0-0.3,0.1-0.6,0.3-0.8c10.3-15.9,19.3-23.9,26.9-23.9 c3.8,0,5.8,3.8,5.8,11.3c0,3.5-1,9.3-2.9,17.3l-6.9,30.3l0.8,0.5c16.5-39.6,31.5-59.4,45.1-59.4c7.1,0,10.7,5.2,10.7,15.7 c0,5.1-0.9,11.8-2.8,20.1L1188.1,163.2z"/>
<path d="M1284,162.4c-0.5,2.4-0.8,4.4-0.8,5.9c0,4.1,0.8,6.2,2.5,6.2c3.4,0,7.9-3.9,13.4-11.8c0.2-0.3,0.7-0.2,1.6,0.3 c0.9,0.4,1.6,1.2,2.1,2.3c0.5,1.1,0.6,1.8,0.4,2.1c-11.6,16.5-20.8,24.7-27.6,24.7c-4,0-6-4.5-6-13.4c0-2.2,0.2-4.5,0.6-6.9l4-22.4 l-1.4-1.4c-6.9,12.5-14,22.9-21.5,31.4c-7.5,8.5-14.5,12.7-21.1,12.7c-4.1,0-7.2-2.2-9.3-6.5c-2.1-4.3-3.1-9.4-3.1-15.1 c0-17.8,5.8-37.1,17.4-57.8c11.6-20.7,23.9-31,37-31c5.4,0,9.8,2.6,13.2,7.9l9.3-51.6c1-5.6,1.5-9.6,1.5-12.1 c0-6.9-2.6-10.3-7.7-10.3c-1,0-1.5-1.1-1.5-3.3c0-2.2,0.5-3.3,1.5-3.3c4.7,0,9.6-1.1,14.9-3.5c5.2-2.3,8-3.5,8.4-3.5 c0.8,0,1.3,0.5,1.3,1.6c0,0.3-0.1,0.8-0.3,1.5L1284,162.4z M1282.9,102.3c-2.9-8.2-7.4-12.3-13.3-12.3c-9,0-17.4,9.3-25.2,28 c-7.7,18.7-11.6,34.7-11.6,48.1c0,8.2,2,12.3,5.9,12.3c4.7,0,11.3-6,20-18.1c8.6-12.1,15.3-23.7,20-34.8L1282.9,102.3z"/>
<path d="M1382,41.5c-3.4-9.6-8.4-14.4-14.8-14.4c-0.8,0-1.3-1.6-1.3-4.8c0-3.2,0.4-4.8,1.3-4.8c3,0.4,10.1,0.6,21.4,0.6 c11.3,0,18.5-0.2,21.7-0.6c0.8,0,1.3,1.6,1.3,4.8c0,3.2-0.4,4.8-1.3,4.8c-7.6,0-11.4,2.4-11.4,7.2c0,2,0.5,4.4,1.5,7.3L1440,152 c0.7,1.6,1.3,2.4,1.8,2.4c0.8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15.4,0.3-26,0.9c-0.8,0-1.3-1.6-1.3-4.7s0.4-4.7,1.3-4.8c12,0,18-4.9,18-14.7v-54.6c0-3.2-1.3-4.8-3.9-4.8h-70.6 c-2.6,0-3.9,1.6-3.9,4.8v54.6c0,9.8,6,14.7,18.1,14.7c0.8,0,1.3,1.6,1.3,4.8c0,3.2-0.4,4.8-1.3,4.8c-10-0.6-18.5-0.9-25.5-0.9 c-7,0-15.9,0.3-26.6,0.9c-0.8,0-1.3-1.6-1.3-4.7s0.4-4.7,1.3-4.8c12,0,18-4.9,18-14.7V41.5c0-9.6-6.3-14.4-19-14.4 c-1,0-1.5-1.6-1.5-4.8c0-3.2,0.5-4.8,1.5-4.8c3,0.4,11.9,0.6,26.6,0.6s23.5-0.2,26.6-0.6c0.8,0,1.3,1.6,1.3,4.8 c0,3.2-0.4,4.8-1.3,4.8c-12.1,0-18.1,4.8-18.1,14.4v49c0,3.3,1.3,4.9,3.9,4.9h70.6c2.6,0,3.9-1.6,3.9-4.9v-49 c0-9.6-6.3-14.4-19-14.4c-1,0-1.5-1.6-1.5-4.8c0-3.2,0.5-4.8,1.5-4.8c3,0.4,11.9,0.6,26.6,0.6c14.7,0,23.5-0.2,26.6-0.6 c0.8,0,1.3,1.6,1.3,4.8c0,3.2-0.4,4.8-1.3,4.8c-12.1,0-18.1,4.8-18.1,14.4V165.3z"/>
</g>
</svg>
</div>

SVG oversized on load until CSS kicks in

I have a SVG inside a fixed-size div (width: 350px; height: 400px;) and everything is fine once the page loads, but during the loading, the SVG is oversized and mangled up until CSS kicks in:
Here is the code, HTML first:
<div class="dashboard-tasks-completed">
<figure>
<svg width="100%" height="100%" viewBox="0 0 42 42" class="donut">
<circle class="donut-hole" cx="21" cy="21" r="15.91549430918954" fill="#fff"></circle>
<circle class="donut-ring" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#19222a" stroke-width="5"></circle>
<circle id="active" class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#206996" stroke-width="5" stroke-dasharray="66.66666666666666 33.33333333333333" stroke-dashoffset="25"></circle>
<circle id="completed" class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#B8E1FA" stroke-width="5" stroke-dasharray="33.33333333333333 66.66666666666666" stroke-dashoffset="58.33333333333334"></circle>
<g class="chart-text">
<text x="50%" y="50%" class="chart-number">3</text>
<text x="50%" y="50%" class="chart-label"> Tasks </text>
</g>
</svg>
<figcaption class="figure-key">
<ul class="figure-key-list" aria-hidden="true" role="presentation">
<li>
<span class="shape-circle shape-blue"></span>2 Active (66.67%)
</li>
<li>
<span class="shape-circle shape-lightblue"></span>1 Completed (33.33%)
</li>
</ul>
</figcaption>
</figure>
</div>
CSS:
.dashboard-tasks-completed {
width: 350px;
height: 400px;
}
.chart-text {
font: 16px/1.4em "Montserrat", Arial, sans-serif;
fill: #000;
transform: translateY(0.25em);
}
.chart-number {
font-size: 0.6em;
line-height: 1;
text-anchor: middle;
transform: translateY(-0.25em);
}
.chart-label {
font-size: 0.2em;
font-weight: bold;
text-transform: uppercase;
text-anchor: middle;
transform: translateY(0.7em);
}
.figure-key-list {
list-style: none;
}
.figure-key-list li {
margin: 0 0 8px;
font-size: 14px;
}
.shape-circle {
display: inline-block;
vertical-align: middle;
width: 32px;
height: 32px;
border-radius: 50%;
margin-right: 10px;
}
.shape-blue { background-color: #206996; }
.shape-lightblue { background-color: #B8E1FA }
I have created a minimal example, unfortunately it is not reproducible in neither JSFiddle or Codepen, but here is the demo in any case.
How can I overcome the issue?
As others have said, you are letting the SVG fill the page until the CSS loads and it becomes the correct size.
If you know your SVG is going to be width: 350px; height: 400px;, then you could set those dimensions on the SVG instead.
<svg width="350px" height="400px" ...>
Then put it back to what you want in the CSS.
.dashboard-tasks-completed svg {
width: 100%;
height: 100%;
}
Or you could inline some basic styling in your document, that would set up some important sizes until the rest of the SVG loads.
<head>
<style>
.dashboard-tasks-completed {
width: 350px;
height: 400px;
}
.chart-text {
font: 16px/1.4em "Montserrat", Arial, sans-serif;
fill: #000;
transform: translateY(0.25em);
}
</style>
...
And if your font size never changes, then why not just set those attributes on your <text> element instead of using CSS?
<g class="chart-text" style="font: 16px/1.4em "Montserrat", Arial, sans-serif; fill: #000; transform: translateY(0.25em);">
One option is to hide the div (or other elements within) initially and then reveal it after the page finishes loading.
For example, modify your div thusly:
<div id="showme" class="dashboard-tasks-completed" style="display:none;">
And then add the following javascript:
window.onload = function () {
document.getElementById("showme").style.display = "block";
};
The inline CSS display:none; lets the browser know not to display it, even before external CSS is loaded. Once everything is loaded, your onload event will fire, and the javascript above will display the previously-hidden elements.
The viewBox attribute defines the position and dimension, in user space, of an SVG viewport.
The value of the viewBox attribute is a list of four numbers min-x, min-y, width and height, separated by whitespace and/or a comma, which specify a rectangle in user space which is mapped to the bounds of the viewport established for the associated SVG element (not the browser viewport).
Taken from MDN.
The viewbox property defines the region of an svg element which should be zoomed in on to fit inside it's container. However, the element will keep it's aspect ratio and not stretch to fit inside the container.
So in your case, this means that the svg element will fill all it's parents space while maintaining it's aspect ratio, until css arrives and tells it to size it self inside a 350px by 400px space.

SVG .fill does not want to work

can somebody please explain to me why I cannot change the fill of this svg:
<div class="container">
<ul class="todo">
<li>
This is an item
<div class ="buttons">
<button class="remove">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 59 59" style="fill;" xml:space="preserve"><g><path d="M29.5,51c0.552,0,1-0.447,1-1V17c0-0.553-0.448-1-1-1s-1,0.447-1,1v33C28.5,50.553,28.948,51,29.5,51z"/><path d="M19.5,51c0.552,0,1-0.447,1-1V17c0-0.553-0.448-1-1-1s-1,0.447-1,1v33C18.5,50.553,18.948,51,19.5,51z"/><path d="M39.5,51c0.552,0,1-0.447,1-1V17c0-0.553-0.448-1-1-1s-1,0.447-1,1v33C38.5,50.553,38.948,51,39.5,51z"/><path d="M52.5,6H38.456c-0.11-1.25-0.495-3.358-1.813-4.711C35.809,0.434,34.751,0,33.499,0H23.5c-1.252,0-2.31,0.434-3.144,1.289C19.038,2.642,18.653,4.75,18.543,6H6.5c-0.552,0-1,0.447-1,1s0.448,1,1,1h2.041l1.915,46.021C10.493,55.743,11.565,59,15.364,59h28.272c3.799,0,4.871-3.257,4.907-4.958L50.459,8H52.5c0.552,0,1-0.447,1-1S53.052,6,52.5,6z M21.792,2.681C22.24,2.223,22.799,2,23.5,2h9.999c0.701,0,1.26,0.223,1.708,0.681c0.805,0.823,1.128,2.271,1.24,3.319H20.553C20.665,4.952,20.988,3.504,21.792,2.681z M46.544,53.979C46.538,54.288,46.4,57,43.636,57H15.364c-2.734,0-2.898-2.717-2.909-3.042L10.542,8h37.915L46.544,53.979z"/></svg> </button>
<button class="complete">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 52 52" style="enable-background:new 0 0 52 52;" xml:space="preserve"><g><path d="M26,0C11.664,0,0,11.663,0,26s11.664,26,26,26s26-11.663,26-26S40.336,0,26,0z M26,50C12.767,50,2,39.233,2,26S12.767,2,26,2s24,10.767,24,24S39.233,50,26,50z"/><path d="M38.252,15.336l-15.369,17.29l-9.259-7.407c-0.43-0.345-1.061-0.274-1.405,0.156c-0.345,0.432-0.275,1.061,0.156,1.406l10,8C22.559,34.928,22.78,35,23,35c0.276,0,0.551-0.114,0.748-0.336l16-18c0.367-0.412,0.33-1.045-0.083-1.411C39.251,14.885,38.62,14.922,38.252,15.336z"/></svg>
</button>
</div>
</li>
</ul>
</div>
Via css I try to manipulate:
ul.todo li .buttons button svg {
width:22px;
height:22px;
position:absolute;
top:50%;
left:50%;
margin:0 0 0 -11px;
}
ul.todo li .buttons button.remove svg .fill {
fill:#c0cecb;
}
ul.todo li .buttons button.remove:hover svg .fill {
fill:#e85656;
}
ul.todo li .buttons button.complete svg .fill {
fill:#25b99a;
}
I imagine the problem is I am not pointing the css at the svg properly, any help is greatly appreciated.
svg .fill {}
... will apply rules to any HTML element that has the fill class and is a descendant of a <svg> tag. If you want to select a <svg> tag that has the fill attribute set, you could use
svg[fill] {}
Please notice the absence of any "" (space character) between the two.
See CSS selectors and CSS combinators for details.
For example, your first rule should be:
ul.todo li .buttons button.remove svg {
fill:#c0cecb;
}
... but that is way too overqualified (overly specific). Most probably...
.todo .button > svg {
fill:#c0cecb;
}
... is more than enough, without the risk of affecting anything else in your website/app.

Apply effect to Element on Hover of Another without JS

I have this code: http://codepen.io/hwg/pen/azZoyp
What I am attempting to do is to apply the blur effect (SVG filter for compatibility) to the other elements on hover of another.
The most important bit of the CSS is as follows
.oi:hover ~ a {color:green;filter: url('#blur');}
This uses the ~ selector in order to effect the siblings of the Link with class of oi. This is fine, but it only affects the elements after the hovered one. Not all of the siblings in the container div.
Is this possible just in CSS?
I've seen that you can use JS as seen here: Using jQuery to Hover over one element and apply the effect in another, and in other questions.
I'd just like to not use JS if possible, would appeciate any help!
Thanks!
Code Embedded:
.btn {
background:lightblue;
padding:1em;
font-family:sans-serif;
margin:0.4em;
display:inline-block;
transition:0.25s all ease-in-out;
border-radius: 5px;
}
.oi ~ a {color:red;}
.oi:hover ~ a {color:green;filter: url('#blur');}
.oi:hover {transform: scale(1.5,1.5);color:red;}
div {margin: 100px auto;display:block;width:100%;}
<div>
<a class="btn">Cholla</a>
<a class="btn">Cholla</a>
<a class="btn oi">Cholla</a>
<a class="btn">Cholla</a>
<a class="btn">Cholla</a>
<a class="btn">Cholla</a>
</div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<filter id="blur">
<feGaussianBlur stdDeviation="5" />
</filter>
</defs>
</svg>
The CSS general sibling selector will only select siblings after that element. (Source: https://developer.mozilla.org/en-US/docs/Web/CSS/General_sibling_selectors)
Use the parent element class, or the btn class instead, and then remove the filter effect with filter:none on the selected element. To wit:
.btn {
background:lightblue;
padding:1em;
font-family:sans-serif;
margin:0.4em;
display:inline-block;
transition:0.25s all ease-in-out;
border-radius: 5px;
color: red;
}
.oi {color:black;}
.btn_wrapper {margin: 100px auto;padding:0;display:block;width:100%;}
.btn_wrapper:hover .btn {color:green;filter: url('#blur');}
.btn_wrapper:hover .btn:hover {transform: scale(1.5,1.5);color:red;filter: none;}
<div class="btn_wrapper">
<a class="btn">Cholla</a>
<a class="btn">Cholla</a>
<a class="btn oi">Cholla</a>
<a class="btn">Cholla</a>
<a class="btn">Cholla</a>
<a class="btn">Cholla</a>
</div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<filter id="blur">
<feGaussianBlur stdDeviation="5" />
</filter>
</defs>
</svg>
Is this possible just in CSS?
Unfortunately, not in a resilient way.
CSS can only descend (cascade) down the DOM, as such selectors can only identify children of an element or siblings appearing after it, at the same level.
In order to achieve what you want you will likely need to resort to a javascript solution- what you wish to achieve would be trivial in jQuery, e.g:
$('.oi').on('mouseover', function(){
$(this).siblings('a')....
});
Alternatively, as close as you will get in CSS is:
.btn {
background: lightblue;
padding: 1em;
font-family: sans-serif;
margin: 0.4em;
display: inline-block;
transition: 0.25s all ease-in-out;
border-radius: 5px;
}
a {
color: red;
}
div:hover a {
color: green;
filter: url('#blur');
}
.oi:hover {
transform: scale(1.5, 1.5);
color: red;
}
div {
margin: 100px auto;
display: block;
width: 100%;
}
<div>
<a class="btn">Cholla</a>
<a class="btn">Cholla</a>
<a class="btn oi">Cholla</a>
<a class="btn">Cholla</a>
<a class="btn">Cholla</a>
<a class="btn">Cholla</a>
</div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<filter id="blur">
<feGaussianBlur stdDeviation="5" />
</filter>
</defs>
</svg>

HTML and CSS: using background image as a clickable link

I'm trying to use a html and css trick to give the impression of using a background image as a clickable link following this tutorial. I can't get to work, however, due to two issues:
1) The link is not filling the space of the background image
2) The link will not move off the screen
I'm using an html code integration block for a weebly website. I'm a beginner to html and CSS.
<a href="website.net/link" title="photo" id=«photo»>photo</a>
<a class="photo"></a>
<style type="text/css">
.photo {
background-image: url(myImageLink.jpg);
background-size: 300px;
background-repeat: no-repeat;
background-position: center;
border-radius: 50%;
background-clip: border-box;
transition: background-size 0.2s;
transition-timing-function: cubic-bezier(.07,1.41,.82,1.41);
display: block;
width: 190px;
height: 190px;
text-decoration: none;
cursor: pointer;
overflow: hidden;
text-indent: 100%;
white-space:nowrap;
}
.photo:hover {
background-size: 500px;
}
</style>
Demo
You need a single <a> tag, style a background to it, give required href to it and make it display: block
html
<a class="photo" href="website.net/link" title="photo" id="photo">photo</a>
css
.photo {
background-image: url('http://www.thinksnaps.com/wp-content/uploads/2014/07/images-background.jpg');
background-size: 300px;
background-repeat: no-repeat;
background-position: center;
border-radius: 50%;
background-clip: border-box;
transition: background-size 0.2s;
transition-timing-function: cubic-bezier(.07,1.41,.82,1.41);
display: block;
width: 190px;
height: 190px;
text-decoration: none;
cursor: pointer;
overflow: hidden;
text-indent: 100%;
white-space:nowrap;
}
.photo:hover {
background-size: 500px;
}
check your html code it should be like this
<a class="photo" href="website.net/link" title="photo" id="photo">photo</a>
Another example how to use .svg images as clickable background. Note that the text on links is hidden by css but may be shown along with clickable .svg images after the text. If you need the images displayed before the text just change ::after pseudo-element for ::before in the snippet below.
UPD: Added material design Google font icons as a clickable background example.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Clickable background</title>
<!-- Citation from http://google.github.io/material-design-icons/#setup-method-1-using-via-google-web-fonts
Similar to other Google Web Fonts, the correct CSS will be served to
activate the 'Material Icons' font specific to the browser. An additional CSS
class will be declared called .material-icons. Any element that uses this
class will have the correct CSS to render these icons from the web font. -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<style type="text/css" media="screen">
/* Make clickable text on links invisible. */
.clickable-background {
font-size:0;
}
.clickable-background:hover ::after, .clickable-background ::after {
content: '';
display:inline-block;
width: 48px;
height: 48px;
/*
The default clickable background image (mouse for PC) to display if no
background image is defined or it is crippled or not reachable. See the
`fill="rgb(255, 0, 0)"' key=value, this is the color (red) of the .svg image.
The width and height are defined above, so no need to change them in the source.
All the images are taken from: https://materialdesignicons.com/
*/
background: url('data:image/svg+xml;utf8,<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" fill="rgb(255, 0, 0)" viewBox="0 0 24 24"><path d="M11,1.07C7.05,1.56 4,4.92 4,9H11M4,15A8,8 0 0,0 12,23A8,8 0 0,0 20,15V11H4M13,1.07V9H20C20,4.92 16.94,1.56 13,1.07Z" /></svg>');
}
/* Every image need to have its own rule defined. */
.stackoverflow-icon ::after{
background: url('data:image/svg+xml;utf8,<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" fill="grey" viewBox="0 0 24 24"><path d="M17.36,20.2V14.82H19.15V22H3V14.82H4.8V20.2H17.36M6.77,14.32L7.14,12.56L15.93,14.41L15.56,16.17L6.77,14.32M7.93,10.11L8.69,8.5L16.83,12.28L16.07,13.9L7.93,10.11M10.19,6.12L11.34,4.74L18.24,10.5L17.09,11.87L10.19,6.12M14.64,1.87L20,9.08L18.56,10.15L13.2,2.94L14.64,1.87M6.59,18.41V16.61H15.57V18.41H6.59Z" /></svg>');
}
/*
The source of images is used instead of image files for the need to change
the color (and may be other svg values) on hover event. It seems a bit redundant
to duplicate the whole image source just for the case, but only foreground
.images can be changed in color with css `fill' property. Let us know if you
discover simpler way to do it. Otherwise you need to edit .svg file before using
it as a downloadable resourse which is the same what we do here.
See more reasons why the source of the .svg image is better than the link to it:
https://css-tricks.com/probably-dont-base64-svg/
*/
.stackoverflow-icon:hover ::after {
background: url('data:image/svg+xml;utf8,<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" fill="blue" viewBox="0 0 24 24"><path d="M17.36,20.2V14.82H19.15V22H3V14.82H4.8V20.2H17.36M6.77,14.32L7.14,12.56L15.93,14.41L15.56,16.17L6.77,14.32M7.93,10.11L8.69,8.5L16.83,12.28L16.07,13.9L7.93,10.11M10.19,6.12L11.34,4.74L18.24,10.5L17.09,11.87L10.19,6.12M14.64,1.87L20,9.08L18.56,10.15L13.2,2.94L14.64,1.87M6.59,18.41V16.61H15.57V18.41H6.59Z" /></svg>');
}
.github-icon ::after{
background: url('data:image/svg+xml;utf8,<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" fill="grey" viewBox="0 0 24 24"><path d="M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z" /></svg>');
}
.github-icon:hover ::after {
background: url('data:image/svg+xml;utf8,<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" fill="blue" viewBox="0 0 24 24"><path d="M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z" /></svg>');
}
/* This rule MUST to be placed under all clickable background rules.*/
.clickable-background:hover ::after, .clickable-background ::after{
background-repeat: no-repeat;
background-size: contain;
}
/*******************************************************************************
Even better solution: clickable Google font material icons expessed as ligatures.
See the <link> tag above.
*******************************************************************************/
/* Make clickable text on links invisible. */
.material-icons {
font-size:0;
}
.material-icons a {
text-decoration: none;
}
.material-icons ::after {
font-size: 48px;
color: grey;
/*
The default clickable background image (crossed phone) to display if no
background image is defined or it is crippled or not reachable.
*/
content: 'phonelink_erase';
}
.material-icons:hover ::after {
color: blue;
}
/* Each clickable font icon need its own rule with the name of a ligature as content property value */
.material-icons.clickable-home ::after {
content: 'home';
}
.material-icons.clickable-thumb_up ::after {
content: 'thumb_up';
}
.material-icons.clickable-android ::after {
content: 'android';
}
.material-icons.clickable-important_devices ::after {
content: 'important_devices';
}
.material-icons.clickable-import_contacts ::after {
content: 'import_contacts';
}
.material-icons.clickable-phonelink_setup ::after {
content: 'phonelink_setup';
}
</style>
</head>
<body>
<p>Note that links below do not lead you to the sites linked because in the code snippet the default behaviour of links is disabled by stackoverflow.com. See the browser status bar and cursor type when hover over links. For actual testing just copy the whole snippet and create your own test.html file.</p>
<span class="clickable-background stackoverflow-icon">
Stackoverflow - sounds good, but the icon is better.
</span>
<span class="clickable-background github-icon">
Github - sounds good, but the icon is better.
</span>
<p>May be even better solution is to use clickable font symbols. Read more about this cool feature on the links below.</p>
</span>
<span class="material-icons clickable-home">
Material design icons
</span>
<span class="material-icons clickable-thumb_up">
Download material icons
</span>
<span class="material-icons clickable-android">
Google fonts
</span>
<span class="material-icons clickable-important_devices">
The Era of Symbol Fonts
</span>
<span class="material-icons clickable-import_contacts">
Material icons' geometric shapes
</span>
<span class="material-icons clickable-phonelink_setup">
Code points reference
</span>
</body>
</html>