how to position svg using div - html
Trying to position svg element by surrounding it by div and adding style to div like float right or padding. After adding div It was all fine but it disappears once i add style to div.
.background {
background: red;
}
.button-text {
text-align: center;
}
.button{
float: right;
padding: 40px;
}
<div class="background">
<div type="button" class="button" >
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 260 39" fill="none">
<path
d="M3.94006 1.22995V18.11H1.02002C0.46002 18.11 0 18.5699 0 19.1299C0 19.6899 0.46002 20.15 1.02002 20.15H3.94006V37.03C3.94006 37.59 4.40008 38.05 4.96008 38.05C5.52008 38.05 5.9801 37.59 5.9801 37.03V1.22995C5.9801 0.66995 5.52008 0.209961 4.96008 0.209961C4.40008 0.209961 3.94006 0.66995 3.94006 1.22995Z"
fill="#FFEC83"
/>
<path
d="M13.3999 0.5H245.96C247.574 0.5 248.88 1.80616 248.88 3.42001V34.84C248.88 36.4539 247.574 37.76 245.96 37.76H13.3999C11.7861 37.76 10.48 36.4539 10.48 34.84V26.93H15.72C16.5561 26.93 17.24 26.2461 17.24 25.41C17.24 24.5738 16.5561 23.89 15.72 23.89H10.48V14.46H15.72C16.5561 14.46 17.24 13.7761 17.24 12.94C17.24 12.1038 16.5561 11.42 15.72 11.42H10.48V3.42001C10.48 1.80614 11.7861 0.5 13.3999 0.5Z"
stroke="#FFEC83"
/>
<path
d="M255.42 1.22995V18.11H258.34C258.9 18.11 259.36 18.57 259.36 19.13C259.36 19.69 258.9 20.15 258.34 20.15H255.42V37.03C255.42 37.59 254.96 38.05 254.4 38.05C253.84 38.05 253.38 37.59 253.38 37.03V1.22995C253.38 0.66995 253.84 0.209961 254.4 0.209961C254.96 0.209961 255.42 0.66995 255.42 1.22995Z"
fill="#FFEC83"
/>
<foreignobject width="260" height="39">
<p class="button-text">SEE ALL NEWS</p>
</foreignobject>
</svg>
</div>
</div>
.background {
background-color: red;
width: 100%;
height: 200px;
}
.button-text {
text-align: center;
}
.button {
float: right;
padding: 40px;
z-index: 100;
width: 260px;
height: 39px;
}
<div class="background">
<div type="button" class="button">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 260 39" fill="none" w>
<path d="M3.94006 1.22995V18.11H1.02002C0.46002 18.11 0 18.5699 0 19.1299C0 19.6899 0.46002 20.15 1.02002 20.15H3.94006V37.03C3.94006 37.59 4.40008 38.05 4.96008 38.05C5.52008 38.05 5.9801 37.59 5.9801 37.03V1.22995C5.9801 0.66995 5.52008 0.209961 4.96008 0.209961C4.40008 0.209961 3.94006 0.66995 3.94006 1.22995Z" fill="#FFEC83" />
<path d="M13.3999 0.5H245.96C247.574 0.5 248.88 1.80616 248.88 3.42001V34.84C248.88 36.4539 247.574 37.76 245.96 37.76H13.3999C11.7861 37.76 10.48 36.4539 10.48 34.84V26.93H15.72C16.5561 26.93 17.24 26.2461 17.24 25.41C17.24 24.5738 16.5561 23.89 15.72 23.89H10.48V14.46H15.72C16.5561 14.46 17.24 13.7761 17.24 12.94C17.24 12.1038 16.5561 11.42 15.72 11.42H10.48V3.42001C10.48 1.80614 11.7861 0.5 13.3999 0.5Z" stroke="#FFEC83" />
<path d="M255.42 1.22995V18.11H258.34C258.9 18.11 259.36 18.57 259.36 19.13C259.36 19.69 258.9 20.15 258.34 20.15H255.42V37.03C255.42 37.59 254.96 38.05 254.4 38.05C253.84 38.05 253.38 37.59 253.38 37.03V1.22995C253.38 0.66995 253.84 0.209961 254.4 0.209961C254.96 0.209961 255.42 0.66995 255.42 1.22995Z" fill="#FFEC83" />
<foreignobject width="260" height="39">
<p class="button-text">SEE ALL NEWS</p>
</foreignobject>
</svg>
</div>
</div>
Related
How to use 2captcha for a webpage where the hcaptcha does not have data-sitekey
I was trying to use 2captcha to scrape this website, but as the 2captcha : hcaptcha page says I need to have a datasite key for the hcaptcha which I am trying to break. But the website which I am scraping does not have any data-sitekey for the element. How can I use 2captcha for such websites? To reproduce : Login to this page using email : something#something.com with password : something. Once you click login you will get the hcaptcha modal. Below is the html for the hcaptcha element <div id="anchor" aria-hidden="false" style="box-sizing: content-box; width: 300px; height: 74px; padding: 0px; margin: 0px; border-width: 1px; border-style: solid; border-radius: 4px; border-color: rgb(224, 224, 224); background-color: rgb(250, 250, 250); cursor: pointer; display: block;"> <div id="anchor-wr" style="position: relative; display: inline-block; height: 100%;"> <div id="anchor-td" style="position: relative; display: table; top: 0px; height: 100%;"> <div id="anchor-tc" style="display: table-cell; vertical-align: middle;"> <div id="anchor-state" style="position: relative; width: 30px; height: 30px; margin: 0px 15px;"> <div id="checkbox" aria-haspopup="true" aria-checked="false" role="checkbox" tabindex="0" aria-live="assertive" aria-labelledby="a11y-label" style="position: absolute; width: 28px; height: 28px; border-width: 1px; border-style: solid; border-color: rgb(145, 145, 145); border-radius: 4px; background-color: rgb(250, 250, 250); top: 0px; left: 0px;"></div> <div class="pulse" style="width: 30px; height: 30px; display: none; position: absolute; top: 0px; left: 0px;"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 44 44" style="width: 30px; height: 30px; display: block;" xml:space="preserve"> <style type="text/css"> .st0 { fill: none; stroke: #FF7B00; stroke-width: 2; } </style> <g> <circle class="st0" cx="22" cy="22" r="1"> <animate accumulate="none" additive="replace" attributeName="r" begin="0s" calcMode="spline" dur="1.8s" fill="remove" keySplines="0.165, 0.84, 0.44, 1" keyTimes="0; 1" repeatCount="indefinite" restart="always" values="1; 20"></animate> <animate accumulate="none" additive="replace" attributeName="stroke-opacity" begin="0s" calcMode="spline" dur="1.8s" fill="remove" keySplines="0.3, 0.61, 0.355, 1" keyTimes="0; 1" repeatCount="indefinite" restart="always" values="1; 0"></animate> </circle> <circle class="st0" cx="22" cy="22" r="1"> <animate accumulate="none" additive="replace" attributeName="r" begin="-0.9s" calcMode="spline" dur="1.8s" fill="remove" keySplines="0.165, 0.84, 0.44, 1" keyTimes="0; 1" repeatCount="indefinite" restart="always" values="1; 20"></animate> <animate accumulate="none" additive="replace" attributeName="stroke-opacity" begin="-0.9s" calcMode="spline" dur="1.8s" fill="remove" keySplines="0.3, 0.61, 0.355, 1" keyTimes="0; 1" repeatCount="indefinite" restart="always" values="1; 0"></animate> </circle> </g> </svg> </div> <div class="check" style="width: 30px; height: 30px; display: none; position: absolute; top: 0px; left: 0px; animation: 0s ease 0s 1 normal none running auto;"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAAC00lEQVR4nO2aTU8TQRyHn39bIdXEm3jwLQhefPkAJorYLYslIF64ohwM8eQH0A/gzYSLIRooxBORKJr4Ultq4smz8YgQb3ow4YAmUHY8IEpgd7vQ3e0smee4+5/uPL+daXdmCwaDwWAwGAwGg8FgMBgM+wBr0u7JFe17QWrTUXcmbqxJuwdhTpDejsHO7Ne5hbJf/b4KYFMeJAuAcKleCPsmgB3ymwiX2m901BZfLHx0a5eKpXcR4ykPgPqdEvnk1Vai7Fgc1JMXkevlm+88p0CiA2hUHhIcQBjykNAAwpKHBAYQpjwkLICw5SFBAUQhDwkJICp5SEAAUcqD5gFELQ8aBxCHPGgaQFzyoGEAccpDwNXgxZmhLCr6sPJTvXk/eRSDYcpDgAAGxgcOZleW31hF+1GUIViTdo9S6qXfna+MlN6HfV3fAApjhdZfrauzInIFkdGoQoh72G/FM4ChmaGW1cPOM+Dav4MRhNBMefAJ4OfK8hjQv+OEyKhV7H0YRgjNmPPb8QxgndQDYMn1pHC30ZHQrDm/Hc8APoy8XVK1dDew6FrQwHTIFe0uRJ43a9hvpW7nc0/6TklmvQq0uxYoNV65VbqDoIJcMFe0uwR5DRxy+bBY5SHgg1B+On9SOZkqqNOuBQFD0E0edvEkuBFCeh7ocC2oE4KO8rCL9wLl4fK3tKOuAguuBT7fCbrKwx7WAvaEfcJJybyCTteCbSNBZ3nY42Ko+2nheKbmVOuFkJuyL+ssDw2sBnNT/cdErVWBMx4ls6D6/B5y4vidr0dDT3PWY+soBzLzwNngrfS485s09HK0crvynbVaDvgSrIVe8hDShsjfkVABznlX6ScPIe4I2dN2W82RisD5nWf1lIeQt8Tsabtt3aEMcuH/UX3lIeQ/SJSGSz9anLQF6vPGEb3lIaJN0cJE4ciaOK9IcV9n+WiJYRPVYDAYDAaDoRH+ALzfixyrasnFAAAAAElFTkSuQmCC" style="width: 30px; height: 30px; display: block;"> </div> </div> </div> </div> <div id="a11y-label" aria-hidden="true" style="display: none;">hCaptcha checkbox. Select in order to trigger the challenge, or to bypass it if you have an accessibility cookie.</div> </div> <div class="label-container" style="position: relative; display: inline-block; height: 100%; width: 170px;"> <label-td style="position: relative; display: table; top: 0px; height: 100%;"> <label-tc style="display: table-cell; vertical-align: middle;"> <div id="label" style="color: rgb(85, 85, 85); font-size: 14px;">I am human</div> </label-tc> </label-td> </div> <div class="anchor-info" style="display: inline-block; height: 100%; width: 65px;"> <div class="anchor-brand" style="margin: 0px auto; top: 6px; position: relative;"> <a class="logo" tabindex="0" target="_blank" href="https://www.hcaptcha.com/what-is-hcaptcha-about?ref=account-api.proton.me&utm_campaign=f99ae21a-1f92-46a4-938e-da6a6afb72ec&utm_medium=checkbox" aria-label="Visit hcaptcha.com to learn more about the service and its accessibility options." style="display: block; width: 44px; height: 50px; margin: 0px auto;"> <div class="logo-graphic" style="cursor: pointer; width: 44px; height: 50px;"> <svg xmlns="http://www.w3.org/2000/svg" width="44" height="46" viewBox="0 0 44 46" fill="none" style="width: 44px; height: 50px; display: block;"> <path opacity="0.5" d="M30 28H26V32H30V28Z" fill="#0074BF"></path> <path opacity="0.7" d="M26 28H22V32H26V28Z" fill="#0074BF"></path> <path opacity="0.7" d="M22 28H18V32H22V28Z" fill="#0074BF"></path> <path opacity="0.5" d="M18 28H14V32H18V28Z" fill="#0074BF"></path> <path opacity="0.7" d="M34 24H30V28H34V24Z" fill="#0082BF"></path> <path opacity="0.8" d="M30 24H26V28H30V24Z" fill="#0082BF"></path> <path d="M26 24H22V28H26V24Z" fill="#0082BF"></path> <path d="M22 24H18V28H22V24Z" fill="#0082BF"></path> <path opacity="0.8" d="M18 24H14V28H18V24Z" fill="#0082BF"></path> <path opacity="0.7" d="M14 24H10V28H14V24Z" fill="#0082BF"></path> <path opacity="0.5" d="M38 20H34V24H38V20Z" fill="#008FBF"></path> <path opacity="0.8" d="M34 20H30V24H34V20Z" fill="#008FBF"></path> <path d="M30 20H26V24H30V20Z" fill="#008FBF"></path> <path d="M26 20H22V24H26V20Z" fill="#008FBF"></path> <path d="M22 20H18V24H22V20Z" fill="#008FBF"></path> <path d="M18 20H14V24H18V20Z" fill="#008FBF"></path> <path opacity="0.8" d="M14 20H10V24H14V20Z" fill="#008FBF"></path> <path opacity="0.5" d="M10 20H6V24H10V20Z" fill="#008FBF"></path> <path opacity="0.7" d="M38 16H34V20H38V16Z" fill="#009DBF"></path> <path d="M34 16H30V20H34V16Z" fill="#009DBF"></path> <path d="M30 16H26V20H30V16Z" fill="#009DBF"></path> <path d="M26 16H22V20H26V16Z" fill="#009DBF"></path> <path d="M22 16H18V20H22V16Z" fill="#009DBF"></path> <path d="M18 16H14V20H18V16Z" fill="#009DBF"></path> <path d="M14 16H10V20H14V16Z" fill="#009DBF"></path> <path opacity="0.7" d="M10 16H6V20H10V16Z" fill="#009DBF"></path> <path opacity="0.7" d="M38 12H34V16H38V12Z" fill="#00ABBF"></path> <path d="M34 12H30V16H34V12Z" fill="#00ABBF"></path> <path d="M30 12H26V16H30V12Z" fill="#00ABBF"></path> <path d="M26 12H22V16H26V12Z" fill="#00ABBF"></path> <path d="M22 12H18V16H22V12Z" fill="#00ABBF"></path> <path d="M18 12H14V16H18V12Z" fill="#00ABBF"></path> <path d="M14 12H10V16H14V12Z" fill="#00ABBF"></path> <path opacity="0.7" d="M10 12H6V16H10V12Z" fill="#00ABBF"></path> <path opacity="0.5" d="M38 8H34V12H38V8Z" fill="#00B9BF"></path> <path opacity="0.8" d="M34 8H30V12H34V8Z" fill="#00B9BF"></path> <path d="M30 8H26V12H30V8Z" fill="#00B9BF"></path> <path d="M26 8H22V12H26V8Z" fill="#00B9BF"></path> <path d="M22 8H18V12H22V8Z" fill="#00B9BF"></path> <path d="M18 8H14V12H18V8Z" fill="#00B9BF"></path> <path opacity="0.8" d="M14 8H10V12H14V8Z" fill="#00B9BF"></path> <path opacity="0.5" d="M10 8H6V12H10V8Z" fill="#00B9BF"></path> <path opacity="0.7" d="M34 4H30V8H34V4Z" fill="#00C6BF"></path> <path opacity="0.8" d="M30 4H26V8H30V4Z" fill="#00C6BF"></path> <path d="M26 4H22V8H26V4Z" fill="#00C6BF"></path> <path d="M22 4H18V8H22V4Z" fill="#00C6BF"></path> <path opacity="0.8" d="M18 4H14V8H18V4Z" fill="#00C6BF"></path> <path opacity="0.7" d="M14 4H10V8H14V4Z" fill="#00C6BF"></path> <path opacity="0.5" d="M30 0H26V4H30V0Z" fill="#00D4BF"></path> <path opacity="0.7" d="M26 0H22V4H26V0Z" fill="#00D4BF"></path> <path opacity="0.7" d="M22 0H18V4H22V0Z" fill="#00D4BF"></path> <path opacity="0.5" d="M18 0H14V4H18V0Z" fill="#00D4BF"></path> <path d="M16.5141 14.9697L17.6379 12.4572C18.0459 11.8129 17.9958 11.0255 17.5449 10.5745C17.4876 10.5173 17.416 10.46 17.3444 10.4171C17.0366 10.2238 16.6572 10.1808 16.3065 10.2954C15.9199 10.4171 15.5835 10.6748 15.3687 11.0184C15.3687 11.0184 13.8297 14.6046 13.2642 16.2153C12.6987 17.8259 12.9206 20.7822 15.1254 22.987C17.4661 25.3277 20.8448 25.8575 23.0066 24.2397C23.0997 24.1967 23.1784 24.1395 23.2572 24.0751L29.9072 18.5202C30.2293 18.2554 30.7089 17.7042 30.2794 17.0743C29.8642 16.4586 29.0697 16.881 28.7404 17.0886L24.9107 19.8731C24.8391 19.9304 24.7318 19.9232 24.6673 19.8517C24.6673 19.8517 24.6673 19.8445 24.6602 19.8445C24.56 19.7228 24.5456 19.4079 24.696 19.2862L30.5657 14.304C31.074 13.8459 31.1456 13.1802 30.7304 12.7292C30.3295 12.2854 29.6924 12.2997 29.1842 12.7578L23.9157 16.881C23.8155 16.9597 23.6652 16.9454 23.5864 16.8452L23.5793 16.838C23.4719 16.7235 23.4361 16.5231 23.5506 16.4014L29.535 10.596C30.0074 10.1522 30.036 9.4149 29.5922 8.94245C29.3775 8.72054 29.084 8.59169 28.7762 8.59169C28.4612 8.59169 28.1606 8.70623 27.9387 8.92813L21.8255 14.6691C21.6823 14.8122 21.396 14.6691 21.3602 14.4973C21.3459 14.4328 21.3674 14.3684 21.4103 14.3255L26.0918 8.99972C26.5571 8.56306 26.5858 7.83292 26.1491 7.36763C25.7124 6.90234 24.9823 6.87371 24.517 7.31036C24.4955 7.32468 24.4812 7.34615 24.4597 7.36763L17.3659 15.2203C17.1082 15.478 16.736 15.4851 16.557 15.342C16.4425 15.2489 16.4282 15.0843 16.5141 14.9697Z" fill="white"></path> <path d="M4.99195 43.6627H3.32946V40.8306C3.32946 40.1764 3.2488 39.6073 2.55423 39.6073C1.85966 39.6073 1.64905 40.2167 1.64905 41.0144V43.6627H0V36.112H1.64905V37.9045C1.64905 38.4512 1.64008 39.0427 1.64008 39.0427C1.89999 38.5632 2.38395 38.1689 3.13677 38.1689C4.61106 38.1689 4.99195 39.1637 4.99195 40.4766V43.6627Z" fill="#555555"></path> <path d="M12.081 42.762C11.7181 43.1563 10.9652 43.7882 9.51337 43.7882C7.42069 43.7882 5.77612 42.3228 5.77612 39.8941C5.77612 37.4564 7.43861 36 9.50889 36C10.9742 36 11.7674 36.6453 11.9556 36.8514L11.4402 38.3167C11.3058 38.1285 10.544 37.5281 9.60299 37.5281C8.39757 37.5281 7.4655 38.3795 7.4655 39.8582C7.4655 41.337 8.43342 42.175 9.60299 42.175C10.4902 42.175 11.131 41.803 11.5209 41.3773L12.081 42.762Z" fill="#555555"></path> <path d="M17.3016 43.6627H15.7242L15.6928 43.0936C15.4777 43.3221 15.0655 43.7837 14.2365 43.7837C13.3403 43.7837 12.3903 43.2684 12.3903 42.0674C12.3903 40.8665 13.4344 40.4587 14.3709 40.4139L15.6525 40.3601V40.2391C15.6525 39.67 15.2716 39.3743 14.6084 39.3743C13.9586 39.3743 13.3089 39.679 13.049 39.8538L12.6143 38.72C13.049 38.4915 13.8421 38.1733 14.7921 38.1733C15.7421 38.1733 16.2888 38.4019 16.6921 38.7962C17.082 39.1906 17.3016 39.7148 17.3016 40.6245V43.6627ZM15.657 41.2877L14.8414 41.3415C14.3351 41.3639 14.0348 41.5924 14.0348 41.9957C14.0348 42.4125 14.353 42.6634 14.8101 42.6634C15.2537 42.6634 15.5539 42.3587 15.657 42.1705V41.2877Z" fill="#555555"></path> <path d="M21.6034 43.7792C20.8506 43.7792 20.3129 43.4835 19.9947 42.9816V45.6389H18.3456V38.2674H19.914L19.9051 38.9575H19.9275C20.2994 38.487 20.8461 38.1689 21.6213 38.1689C23.0867 38.1689 24.0142 39.3832 24.0142 40.9696C24.0142 42.5559 23.0777 43.7792 21.6034 43.7792ZM21.1284 39.549C20.4249 39.549 19.9409 40.1181 19.9409 40.9471C19.9409 41.7762 20.4249 42.3453 21.1284 42.3453C21.8409 42.3453 22.3249 41.7762 22.3249 40.9471C22.3249 40.1181 21.8409 39.549 21.1284 39.549Z" fill="#555555"></path> <path d="M27.8321 39.6028H26.7074V41.5386C26.7074 42.0002 26.7701 42.1077 26.8508 42.2063C26.9225 42.296 27.0255 42.3363 27.2406 42.3363C27.4109 42.3318 27.5767 42.3004 27.738 42.2377L27.8187 43.6044C27.4378 43.7165 27.039 43.7747 26.6446 43.7792C26.0576 43.7792 25.6633 43.591 25.4079 43.2773C25.1524 42.9636 25.0449 42.511 25.0449 41.691V39.6028H24.3234V38.2809H25.0449V36.8156H26.7074V38.2809H27.8321V39.6028Z" fill="#555555"></path> <path d="M32.7121 43.1339C32.6583 43.1787 32.1251 43.7792 30.7718 43.7792C29.3781 43.7792 28.0876 42.771 28.0876 40.9785C28.0876 39.1726 29.3961 38.1689 30.7897 38.1689C32.0892 38.1689 32.6762 38.738 32.6762 38.738L32.3133 40.0599C31.9458 39.7507 31.4843 39.5804 31.0048 39.5804C30.3013 39.5804 29.7456 40.0957 29.7456 40.9471C29.7456 41.7986 30.252 42.3363 31.0272 42.3363C31.8024 42.3363 32.3178 41.812 32.3178 41.812L32.7121 43.1339Z" fill="#555555"></path> <path d="M38.3986 43.6627H36.7361V40.8306C36.7361 40.1764 36.6555 39.6073 35.9609 39.6073C35.2663 39.6073 35.0512 40.2212 35.0512 41.0188V43.6672H33.4067V36.112H35.0557V37.9045C35.0557 38.4512 35.0468 39.0427 35.0468 39.0427C35.3067 38.5632 35.7906 38.1689 36.5435 38.1689C38.0177 38.1689 38.3986 39.1637 38.3986 40.4766V43.6627Z" fill="#555555"></path> <path d="M44 43.6627H42.4226L42.3913 43.0936C42.1762 43.3221 41.7639 43.7837 40.9349 43.7837C40.0387 43.7837 39.0887 43.2684 39.0887 42.0674C39.0887 40.8665 40.1328 40.4587 41.0693 40.4139L42.3509 40.3601V40.2391C42.3509 39.67 41.97 39.3743 41.3068 39.3743C40.6571 39.3743 40.0073 39.679 39.7474 39.8538L39.3127 38.7156C39.7474 38.487 40.5406 38.1689 41.4906 38.1689C42.4405 38.1689 42.9872 38.3974 43.3905 38.7917C43.7804 39.1861 44 39.7104 44 40.62V43.6627ZM42.3599 41.2877L41.5443 41.3415C41.038 41.3639 40.7377 41.5924 40.7377 41.9957C40.7377 42.4125 41.0559 42.6634 41.513 42.6634C41.9566 42.6634 42.2568 42.3587 42.3599 42.1705V41.2877V41.2877Z" fill="#555555"></path> </svg> </div> </a> </div> <div class="anchor-links" style="text-align: right; position: fixed; bottom: 9px; right: 12px;"> <a class="link" tabindex="0" aria-label="hCaptcha Privacy Policy" style="color: rgb(85, 85, 85); font-weight: 500; font-size: 8px; cursor: pointer; text-decoration: none; display: inline-block; line-height: 8px;">Privacy</a> <span style="color: rgb(85, 85, 85); font-weight: 500; font-size: 8px; line-height: 8px;"> - </span> <a class="link" tabindex="0" aria-label="hCaptcha Terms of Service" style="color: rgb(85, 85, 85); font-weight: 500; font-size: 8px; cursor: pointer; text-decoration: none; display: inline-block; line-height: 8px;">Terms</a> </div> </div> <div id="status" aria-hidden="true" aria-live="polite" style="display: none; color: rgb(235, 87, 87); font-size: 10px; top: 5px; left: 5px; position: absolute;"></div> <div id="warning" aria-hidden="true" aria-live="polite" style="display: none; color: rgb(235, 87, 87); font-size: 10px; bottom: 5px; left: 5px; width: 75%; position: absolute;"></div> </div>
Change fill color in a SVG when hover
How can I change the fill color from this SVG button on hover please ? The CSS rule I have tried: .svg-button:hover { fill: #cc662f; transition: 0.3s; } <p class="svg-button"> <a href="" target="_blank"> <svg xmlns="http://www.w3.org/2000/svg" width="325" height="50"><g data-name="Composant 18 – 1"><g data-name="Groupe 129"><g data-name="Rectangle 6"><g data-name="Groupe 126"><g data-name="Groupe 125"><path data-name="Tracé 9925" d="M29.12 3.476c44.518 0 44.518-2.754 89.037-2.754s44.52 1.14 89.041 1.14 44.522 2.981 89.042 2.981c15.382 0 28.872 7.712 28.872 19.862h-2.353c0 12.15-11.138 24.2-26.519 24.2-44.519 0-44.519-4.563-89.037-4.563s-44.521 3.767-89.042 3.767-44.521.385-89.041.385c-15.381 0-27.1-11.644-27.1-23.794h-.571C1.445 12.555 13.739 3.476 29.12 3.476Z" fill="none" stroke="#cc662f"/></g></g></g><g data-name="Rectangle 6"><g data-name="Groupe 128"><g data-name="Groupe 127"><path data-name="Tracé 9926" d="M296.492 45.934c-44.519 0-44.519 2.754-89.037 2.754s-44.522-1.139-89.042-1.139-44.52-2.982-89.041-2.982C13.99 44.567.5 36.855.5 24.705h2.352c0-12.15 11.138-24.2 26.52-24.2 44.518 0 44.518 4.563 89.037 4.563s44.521-3.766 89.041-3.766 44.522-.386 89.042-.386c15.382 0 27.1 11.644 27.1 23.794h.571c.005 12.145-12.289 21.224-27.671 21.224Z" fill="none" stroke="#cc662f"/></g></g></g></g><text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle">CTA</text></g></svg> </a> </p> Thanks.
You need to change the fill property for the path in the svg on a:hover. So for example: .svg-button a:hover svg path { fill: #cc662f; transition: 0.3s; } <p class="svg-button"> <a href="" target="_blank"> <svg xmlns="http://www.w3.org/2000/svg" width="325" height="50"><g data-name="Composant 18 – 1"><g data-name="Groupe 129"><g data-name="Rectangle 6"><g data-name="Groupe 126"><g data-name="Groupe 125"><path data-name="Tracé 9925" d="M29.12 3.476c44.518 0 44.518-2.754 89.037-2.754s44.52 1.14 89.041 1.14 44.522 2.981 89.042 2.981c15.382 0 28.872 7.712 28.872 19.862h-2.353c0 12.15-11.138 24.2-26.519 24.2-44.519 0-44.519-4.563-89.037-4.563s-44.521 3.767-89.042 3.767-44.521.385-89.041.385c-15.381 0-27.1-11.644-27.1-23.794h-.571C1.445 12.555 13.739 3.476 29.12 3.476Z" fill="none" stroke="#cc662f"/></g></g></g><g data-name="Rectangle 6"><g data-name="Groupe 128"><g data-name="Groupe 127"><path data-name="Tracé 9926" d="M296.492 45.934c-44.519 0-44.519 2.754-89.037 2.754s-44.522-1.139-89.042-1.139-44.52-2.982-89.041-2.982C13.99 44.567.5 36.855.5 24.705h2.352c0-12.15 11.138-24.2 26.52-24.2 44.518 0 44.518 4.563 89.037 4.563s44.521-3.766 89.041-3.766 44.522-.386 89.042-.386c15.382 0 27.1 11.644 27.1 23.794h.571c.005 12.145-12.289 21.224-27.671 21.224Z" fill="none" stroke="#cc662f"/></g></g></g></g><text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle">CTA</text></g></svg> </a> </p> But I would rather assign the class to the link. Let the a act as a button, and the p tag perform its intended functions as a paragraph of the text. .svg-button:hover path { fill: #cc662f; transition: 0.3s; } <p> <a class="svg-button" href="" target="_blank"> <svg xmlns="http://www.w3.org/2000/svg" width="325" height="50"><g data-name="Composant 18 – 1"><g data-name="Groupe 129"><g data-name="Rectangle 6"><g data-name="Groupe 126"><g data-name="Groupe 125"><path data-name="Tracé 9925" d="M29.12 3.476c44.518 0 44.518-2.754 89.037-2.754s44.52 1.14 89.041 1.14 44.522 2.981 89.042 2.981c15.382 0 28.872 7.712 28.872 19.862h-2.353c0 12.15-11.138 24.2-26.519 24.2-44.519 0-44.519-4.563-89.037-4.563s-44.521 3.767-89.042 3.767-44.521.385-89.041.385c-15.381 0-27.1-11.644-27.1-23.794h-.571C1.445 12.555 13.739 3.476 29.12 3.476Z" fill="none" stroke="#cc662f"/></g></g></g><g data-name="Rectangle 6"><g data-name="Groupe 128"><g data-name="Groupe 127"><path data-name="Tracé 9926" d="M296.492 45.934c-44.519 0-44.519 2.754-89.037 2.754s-44.522-1.139-89.042-1.139-44.52-2.982-89.041-2.982C13.99 44.567.5 36.855.5 24.705h2.352c0-12.15 11.138-24.2 26.52-24.2 44.518 0 44.518 4.563 89.037 4.563s44.521-3.766 89.041-3.766 44.522-.386 89.042-.386c15.382 0 27.1 11.644 27.1 23.794h.571c.005 12.145-12.289 21.224-27.671 21.224Z" fill="none" stroke="#cc662f"/></g></g></g></g><text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle">CTA</text></g></svg> </a> </p>
By tweaking your svg, you could gain additional styling controls: <path d="..." stroke="#cc662f" > remove fill attribute. <text fill="currentColor" x="50%" y="50%" text-anchor="middle">CTA</text> fill="currentColor": your text element will inherit its parent's text color. This way you could also change the text color on hover. Besides you don't even need to select the <path>elements: .svg-button { fill: none; color: #333; stroke: "#cc662f"; } a:hover .svg-button { fill: #cc662f; color: #fff; font-weight: bold; transition: 0.3s; } <p> <a class="a-svg-button" href="#" target="_blank"> <svg class="svg-button" xmlns="http://www.w3.org/2000/svg" width="325" height="50"> <g data-name="Composant 18 – 1"> <g data-name="Groupe 129"> <g data-name="Rectangle 6"> <g data-name="Groupe 126"> <g data-name="Groupe 125"> <path data-name="Tracé 9925" d="M29.12 3.476c44.518 0 44.518-2.754 89.037-2.754s44.52 1.14 89.041 1.14 44.522 2.981 89.042 2.981c15.382 0 28.872 7.712 28.872 19.862h-2.353c0 12.15-11.138 24.2-26.519 24.2-44.519 0-44.519-4.563-89.037-4.563s-44.521 3.767-89.042 3.767-44.521.385-89.041.385c-15.381 0-27.1-11.644-27.1-23.794h-.571C1.445 12.555 13.739 3.476 29.12 3.476Z" stroke="#cc662f" /> </g> </g> </g> <g data-name="Rectangle 6"> <g data-name="Groupe 128"> <g data-name="Groupe 127"> <path data-name="Tracé 9926" d="M296.492 45.934c-44.519 0-44.519 2.754-89.037 2.754s-44.522-1.139-89.042-1.139-44.52-2.982-89.041-2.982C13.99 44.567.5 36.855.5 24.705h2.352c0-12.15 11.138-24.2 26.52-24.2 44.518 0 44.518 4.563 89.037 4.563s44.521-3.766 89.041-3.766 44.522-.386 89.042-.386c15.382 0 27.1 11.644 27.1 23.794h.571c.005 12.145-12.289 21.224-27.671 21.224Z" stroke="#cc662f" /> </g> </g> </g> </g><text fill="currentColor" x="50%" y="50%" dominant-baseline="middle" text-anchor="middle">CTA</text> </g> </svg> </a> </p> Further reading: How to change the color of an svg element?
Masked svg element not showing whole svg item
In this example I am trying to scroll a masked container item using transform: translate and animation: infinite. Problem is that only a small partition of the masked container item is scrolling. How would I get it scrolling as it does in the imgur link below? * { margin: 0; padding: 0; box-sizing: border-box; } body { text-align: center; margin: 20px; } #code-main { animation: code 3s infinite; } #keyframes code { from { transform: translate(0px, 0px); } to { transform: translate(0px, 150px); } } <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="styles.css"> <title>Document</title> </head> <body> <svg width="712" height="670" viewBox="0 0 712 670" fill="none" xmlns="http://www.w3.org/2000/svg"> <g id="undraw_feeling_proud_qne1 1"> <g clip-path="url(#clip0)"> <g id="guy"> <path id="Vector" d="M516.326 380.047V565.042L547.27 615.472L549.625 619.308H671.722L674.189 380.047H516.326Z" fill="#E6E6E6"/> <path id="Vector_2" opacity="0.1" d="M516.326 380.047V565.042L547.27 615.472L549.169 380.047H516.326Z" fill="black"/> <path id="Vector_3" d="M221.566 375.113V560.109L190.622 610.539L188.267 614.374H66.17L63.703 375.113H221.566Z" fill="#E6E6E6"/> <path id="Vector_4" opacity="0.1" d="M221.566 375.113V560.109L190.622 610.539L188.723 375.113H221.566Z" fill="black"/> <path id="Vector_5" d="M711.188 371.414V382.513H47.67V366.48L109.335 334.414H656.923L711.188 371.414Z" fill="#E6E6E6"/> <path id="Vector_6" opacity="0.1" d="M711.188 371.414V382.513H47.67V366.48L711.188 371.414Z" fill="black"/> <path id="Vector_7" d="M142.635 426.912H113.035L100.702 418.279H156.201L142.635 426.912Z" fill="#3F3D56"/> <path id="Vector_8" d="M142.635 462.678H113.035L100.702 454.045H156.201L142.635 462.678Z" fill="#3F3D56"/> <path id="Vector_9" d="M142.635 513.244H113.035L100.702 504.61H156.201L142.635 513.244Z" fill="#3F3D56"/> <path id="Vector_10" d="M142.635 563.809H113.035L100.702 555.176H156.201L142.635 563.809Z" fill="#3F3D56"/> <path id="Vector_11" d="M595.257 431.845H624.857L637.19 423.212H581.691L595.257 431.845Z" fill="#3F3D56"/> <path id="Vector_12" d="M595.257 467.611H624.857L637.19 458.978H581.691L595.257 467.611Z" fill="#3F3D56"/> <path id="Vector_13" d="M595.257 518.177H624.857L637.19 509.544H581.691L595.257 518.177Z" fill="#3F3D56"/> <path id="Vector_14" d="M595.257 568.742H624.857L637.19 560.109H581.691L595.257 568.742Z" fill="#3F3D56"/> <path id="Vector_15" d="M490.821 127.605C491.695 127.605 492.403 126.897 492.403 126.023C492.403 125.149 491.695 124.44 490.821 124.44C489.947 124.44 489.239 125.149 489.239 126.023C489.239 126.897 489.947 127.605 490.821 127.605Z" fill="#F2F2F2"/> <path id="Vector_16" d="M490.821 300.387C494.142 300.387 496.834 297.695 496.834 294.374C496.834 291.053 494.142 288.362 490.821 288.362C487.5 288.362 484.809 291.053 484.809 294.374C484.809 297.695 487.5 300.387 490.821 300.387Z" fill="#F2F2F2"/> <path id="Vector_17" d="M481.452 357.981V361.146H311.202V358.614L311.436 357.981L315.632 346.589H477.971L481.452 357.981Z" fill="#3F3D56"/> <path id="Vector_18" d="M546.97 354.883C546.659 356.208 545.489 357.607 542.843 358.93C533.35 363.677 514.046 357.664 514.046 357.664C514.046 357.664 499.173 355.133 499.173 348.487C499.59 348.201 500.026 347.942 500.477 347.712C504.468 345.6 517.702 340.39 541.167 347.932C542.896 348.475 544.44 349.487 545.628 350.855C546.154 351.373 546.55 352.008 546.783 352.708C547.016 353.408 547.08 354.153 546.97 354.883Z" fill="#3F3D56"/> <path id="Vector_19" opacity="0.1" d="M546.97 354.883C535.35 359.335 524.992 359.667 514.363 352.284C510.343 349.313 505.476 347.71 500.477 347.712C504.468 345.6 517.702 340.39 541.167 347.932C542.896 348.475 544.44 349.487 545.628 350.855C546.154 351.373 546.55 352.008 546.783 352.708C547.016 353.408 547.08 354.153 546.97 354.883Z" fill="black"/> <path id="Vector_20" d="M532.4 352.284C534.672 352.284 536.514 351.718 536.514 351.019C536.514 350.32 534.672 349.753 532.4 349.753C530.128 349.753 528.286 350.32 528.286 351.019C528.286 351.718 530.128 352.284 532.4 352.284Z" fill="#F2F2F2"/> <path id="Vector_21" opacity="0.1" d="M481.452 357.981V361.146H311.202V358.614L311.436 357.981H481.452Z" fill="black"/> <path id="Vector_22" d="M94.6615 0.0286924C92.9336 -0.113172 91.2035 0.273333 89.7002 1.13699C88.2242 2.14779 87.2939 3.91861 86.3443 5.56646C82.7136 11.9421 77.7985 17.4942 71.9101 21.8711C67.6211 25.0131 62.1684 28.9308 62.9022 34.7238C63.2893 36.6369 63.996 38.4711 64.9927 40.1493C68.9493 48.1363 79.7463 54.3086 78.6843 63.4224C82.6153 56.8415 77.3573 53.5874 81.2883 47.0065C83.1604 43.8725 86.4124 40.3348 89.2388 42.303C90.1852 42.962 90.8066 44.1439 91.792 44.7222C94.1432 46.1019 96.6446 43.4642 98.7259 41.5958C105.903 35.1532 116.109 36.841 125.04 38.8484C129.256 39.7961 133.887 41.0394 136.379 45.0691C139.656 50.3673 133.266 56.0894 131.651 62.0796C131.52 62.59 131.513 63.1248 131.633 63.6381C131.753 64.1514 131.996 64.6281 132.34 65.0273C132.684 65.4266 133.12 65.7365 133.61 65.9305C134.1 66.1246 134.63 66.1971 135.154 66.1417C137.834 65.8774 141.009 65.6607 141.167 64.4848C144.539 64.6048 148.67 64.223 150.114 60.7123C150.556 59.3233 150.789 57.8765 150.807 56.4191C151.337 50.5219 153.84 45.1419 155.498 39.5292C157.156 33.9164 157.877 27.3387 155.079 22.3624C154.08 20.7067 152.845 19.2057 151.413 17.9068C135.534 2.54006 114.657 0.00588238 94.6615 0.0286924Z" fill="#2F2E41"/> <path id="Vector_23" d="M82.1377 74.9337C82.1377 74.9337 85.5911 103.712 72.9286 106.014C60.2661 108.317 84.4399 147.455 84.4399 147.455L141.997 154.362L128.183 108.317C128.183 108.317 118.974 104.863 124.73 81.8406C130.485 58.8178 82.1377 74.9337 82.1377 74.9337Z" fill="#FFB8B8"/> <path id="Vector_24" d="M47.028 569.347L51.633 632.66H75.806L68.9 569.347H47.028Z" fill="#FFB8B8"/> <path id="Vector_25" d="M224.303 449.629L227.756 502.581L254.233 491.07L243.872 447.327L224.303 449.629Z" fill="#FFB8B8"/> <path id="Vector_26" d="M29.761 327.608C29.761 327.608 30.9121 394.374 37.819 416.246C44.7259 438.117 43.5747 439.268 42.4236 442.722C41.2724 446.175 40.1213 443.873 40.1213 449.629C40.1213 455.384 37.819 546.324 40.1213 554.382C42.4235 562.44 33.2145 576.254 40.1213 577.405C47.0281 578.556 79.2599 577.405 80.411 570.498C81.5622 563.591 71.202 561.289 75.8065 556.684C80.4111 552.08 87.3179 457.687 87.3179 457.687L103.434 392.072L133.363 357.538H196.676L216.245 433.513C216.245 433.513 208.187 455.384 213.943 455.384C219.699 455.384 254.233 462.291 254.233 436.966C254.233 411.641 242.721 336.817 240.419 334.515C238.117 332.213 241.57 324.155 238.117 320.701C234.663 317.248 194.374 293.074 179.409 288.47C164.444 283.865 143.451 278.385 143.451 278.385L29.761 327.608Z" fill="#2F2E41"/> <path id="Vector_27" d="M254.233 481.86C254.233 481.86 236.966 476.105 228.908 493.372C220.85 510.639 224.303 515.243 224.303 515.243C224.303 515.243 250.779 524.452 255.384 519.848C257.387 517.845 263.748 517.149 270.296 517.002C280.269 516.778 282.923 502.668 273.504 499.383C273.223 499.285 272.939 499.2 272.651 499.127C263.442 496.825 254.233 481.86 254.233 481.86Z" fill="#2F2E41"/> <path id="Vector_28" d="M108.038 93.9275C127.111 93.9275 142.572 78.4661 142.572 59.3934C142.572 40.3208 127.111 24.8593 108.038 24.8593C88.9656 24.8593 73.5042 40.3208 73.5042 59.3934C73.5042 78.4661 88.9656 93.9275 108.038 93.9275Z" fill="#FFB8B8"/> <path id="Vector_29" d="M63.144 120.404C63.144 120.404 119.55 131.915 133.363 113.497C147.177 95.0786 152.933 165.298 152.933 165.298L159.839 238.971L149.479 279.26C149.479 279.26 95.3758 323.004 78.1087 326.457C60.8417 329.91 34.3655 332.213 34.3655 332.213C34.3655 332.213 42.4236 204.437 42.4236 202.134C42.4236 199.832 63.144 120.404 63.144 120.404Z" fill="#6C63FF"/> <path id="Vector_30" d="M80.2983 98.8144C80.2983 98.8144 67.7485 91.6252 64.2951 98.532C60.8417 105.439 28.6099 122.706 25.1565 122.706C21.7031 122.706 32.0633 218.25 27.4587 229.762C22.8542 241.273 0.982611 325.306 13.6451 332.213C26.3076 339.119 17.0985 325.306 29.761 342.573C42.4235 359.84 104.585 359.84 108.038 352.933C111.492 346.026 80.411 294.225 86.1667 245.877C91.9224 197.53 101.131 130.764 93.0735 121.555C85.0156 112.346 80.2983 98.8144 80.2983 98.8144Z" fill="#2F2E41"/> <path id="Vector_31" d="M121.852 106.59L123.455 101.072C123.455 101.072 171.351 116.95 173.653 127.31C175.955 137.671 174.804 210.192 166.746 215.948C158.688 221.704 147.177 230.913 155.235 244.726C163.293 258.54 172.502 273.505 179.409 274.656C186.316 275.807 198.978 283.865 195.525 291.923C192.071 299.981 150.63 285.016 150.63 285.016C150.63 285.016 123.003 264.296 124.154 232.064C125.305 199.832 121.852 106.59 121.852 106.59Z" fill="#2F2E41"/> <path id="Vector_32" d="M162.142 242.424L134.514 294.225C134.514 294.225 94.2246 335.666 117.247 340.271C140.27 344.875 152.933 302.283 152.933 302.283L182.862 259.691L162.142 242.424Z" fill="#FFB8B8"/> <path id="Vector_33" d="M96.3438 9.06446C94.9518 8.96132 93.5575 9.23175 92.3051 9.8478C91.1726 10.6749 90.2393 11.7445 89.5733 12.9785C86.5029 17.5971 82.5005 21.5224 77.8232 24.5025C74.3318 26.7233 69.893 29.4922 70.4904 33.5867C70.8146 34.9595 71.3917 36.2599 72.1922 37.4214C75.4241 43.1236 76.7108 49.7234 75.8574 56.2221L85.4575 42.2681C86.9814 40.053 89.6287 37.5526 91.9296 38.9437C92.6999 39.4095 93.2058 40.2449 94.0079 40.6535C95.9219 41.6287 97.9581 39.7644 99.6524 38.4439C105.495 33.8903 113.803 35.0832 121.073 36.502C124.505 37.1718 128.275 38.0506 130.304 40.8987C133.676 45.6319 130.155 52.4709 132.123 57.9388C132.674 57.5531 133.141 57.0608 133.498 56.491C133.855 55.9211 134.095 55.2855 134.201 54.6216C136.946 54.7064 140.309 54.4366 141.485 51.9552C141.842 50.9828 142.033 49.9568 142.049 48.9208C142.48 44.7527 144.518 40.9502 145.867 36.9831C147.217 33.0161 147.804 28.367 145.526 24.8497C144.693 23.658 143.687 22.5967 142.542 21.7006C129.616 10.8395 112.621 9.04834 96.3438 9.06446Z" fill="#2F2E41"/> <path id="Vector_34" d="M162.142 122.706L172.867 125.553C172.867 125.553 197.827 189.472 192.071 233.215C186.316 276.958 182.862 267.749 182.862 267.749C182.862 267.749 173.653 247.029 152.933 251.633L162.142 122.706Z" fill="#2F2E41"/> <path id="Vector_35" d="M48.6229 624.292C45.847 628.064 46.4035 633.456 43.9446 637.443C41.8132 640.898 37.7962 642.71 35.1302 645.771C34.2795 646.788 33.5212 647.879 32.8641 649.031C30.391 653.174 28.3808 658.483 30.8165 662.648C32.7758 665.998 36.8943 667.307 40.6715 668.2C45.4455 669.328 50.4058 670.23 55.235 669.368C60.0642 668.506 64.7838 665.549 66.5057 660.956C66.8441 659.801 67.2464 658.666 67.7108 657.555C70.3282 652.402 78.5383 652.347 81.217 647.225C83.0917 643.641 81.3684 639.309 79.6459 635.649L74.3848 624.472C72.6389 620.763 65.5611 622.896 61.8714 622.007C57.0591 620.848 52.0848 619.571 48.6229 624.292Z" fill="#2F2E41"/> <path id="Vector_36" d="M10.1917 265.447L58.5394 340.271C58.5394 340.271 88.4689 378.258 97.678 360.991C106.887 343.724 65.4462 314.946 65.4462 314.946L34.3655 257.389L10.1917 265.447Z" fill="#FFB8B8"/> <path id="Vector_37" d="M34.3655 125.008L25.1564 122.706C25.1564 122.706 6.73827 128.462 2.13372 152.635C-2.47081 176.809 0.982583 273.505 6.73826 274.656C12.4939 275.807 35.1655 257.819 38.7945 261.633C42.4235 265.447 30.9121 245.877 34.3655 235.517C37.8189 225.157 34.3655 125.008 34.3655 125.008Z" fill="#2F2E41"/> <path id="Vector_38" d="M615.414 120.485H366.228C364.991 120.485 363.765 120.728 362.622 121.202C361.478 121.675 360.439 122.37 359.564 123.245C358.689 124.12 357.995 125.159 357.522 126.302C357.048 127.446 356.804 128.671 356.805 129.909V297.766C356.804 299.004 357.048 300.23 357.522 301.373C357.995 302.516 358.689 303.555 359.564 304.43C360.439 305.306 361.478 306 362.622 306.473C363.765 306.947 364.991 307.19 366.228 307.19H460.821L457.277 329.817C457.277 329.817 437.025 340.576 451.265 340.892C465.505 341.209 532.593 340.892 532.593 340.892C532.593 340.892 545.567 340.892 524.998 329.5L521.664 307.19H615.414C616.651 307.19 617.877 306.947 619.02 306.473C620.164 306 621.203 305.306 622.078 304.43C622.953 303.555 623.647 302.516 624.121 301.373C624.594 300.23 624.838 299.004 624.838 297.766V129.909C624.838 128.671 624.594 127.446 624.121 126.302C623.647 125.159 622.953 124.12 622.078 123.245C621.203 122.37 620.164 121.675 619.02 121.202C617.877 120.728 616.651 120.485 615.414 120.485Z" fill="#3F3D56"/> </g> <path id="Vector_39" d="M616 130H366V270H616V130Z" fill="#F2F2F2"/> <mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="366" y="130" width="250" height="140"> <path id="Vector_40" d="M616 130H366V270H616V130Z" fill="#F2F2F2"/> </mask> <g mask="url(#mask0)"> <g id="code-main" filter="url(#filter0_d)"> <g id="code-main_2"> <g id="Group 15"> <path id="Rectangle 59" d="M424.752 164.345H395V171.444H424.752V164.345Z" fill="#6C63FF"/> <path id="Rectangle 60" d="M527.784 164.345H517.315V171.444H527.784V164.345Z" fill="#6C63FF"/> <path id="Rectangle 61" d="M548.721 164.345H538.252V171.444H548.721V164.345Z" fill="#6C63FF"/> <path id="Rectangle 62" d="M506.296 164.345H435.221V171.444H506.296V164.345Z" fill="#6C63FF"/> <path id="Rectangle 63" d="M547.619 134.308H517.866V141.408H547.619V134.308Z" fill="#6C63FF"/> <path id="Rectangle 64" d="M587.839 134.308H558.087V141.408H587.839V134.308Z" fill="#6C63FF"/> <path id="Rectangle 66" d="M405.468 134.308H395V141.408H405.468V134.308Z" fill="#6C63FF"/> <path id="Rectangle 67" d="M426.405 134.308H415.937V141.408H426.405V134.308Z" fill="#6C63FF"/> <path id="Rectangle 68" d="M507.949 134.308H436.874V141.408H507.949V134.308Z" fill="#6C63FF"/> <path id="Rectangle 69" d="M485.91 149.6H456.158V156.699H485.91V149.6Z" fill="#6C63FF"/> <path id="Rectangle 70" d="M445.689 149.6H415.937V156.699H445.689V149.6Z" fill="#6C63FF"/> <path id="Rectangle 71" d="M405.468 149.6H395V156.699H405.468V149.6Z" fill="#6C63FF"/> <path id="Rectangle 73" d="M587.839 149.6H577.371V156.699H587.839V149.6Z" fill="#6C63FF"/> <path id="Rectangle 74" d="M566.902 149.6H495.827V156.699H566.902V149.6Z" fill="#6C63FF"/> </g> </g> </g> </g> </g> </g> <defs> <filter id="filter0_d" x="391" y="-181" width="200.839" height="360.444" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"> <feFlood flood-opacity="0" result="BackgroundImageFix"/> <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/> <feOffset dy="4"/> <feGaussianBlur stdDeviation="2"/> <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/> <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/> <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/> </filter> <clipPath id="clip0"> <rect width="711.188" height="669.683" fill="white"/> </clipPath> </defs> </svg> </body> </html> Codepen: https://codepen.io/DevKris/pen/KKpVxVa Desired outcome: https://imgur.com/a/lG7vgem
You need to reuse the #Group15 several times: Also I would use ids with no sapces: i.e. id="Group15" instead of id="Group 15" I hope this is what you are asking. * { margin: 0; padding: 0; box-sizing: border-box; } body { text-align:center; margin: 20px; } #code-main { animation: code 3s infinite; } #keyframes code { from { transform: translate(0px, 0px); } to { transform: translate(0px, 150px); } } <svg width="712" height="670" viewBox="0 0 712 670" fill="none" xmlns="http://www.w3.org/2000/svg"> <g id="undraw_feeling_proud_qne1 1"> <g clip-path="url(#clip0)"> <g id="guy"> <path id="Vector_38" d="M615.414 120.485H366.228C364.991 120.485 363.765 120.728 362.622 121.202C361.478 121.675 360.439 122.37 359.564 123.245C358.689 124.12 357.995 125.159 357.522 126.302C357.048 127.446 356.804 128.671 356.805 129.909V297.766C356.804 299.004 357.048 300.23 357.522 301.373C357.995 302.516 358.689 303.555 359.564 304.43C360.439 305.306 361.478 306 362.622 306.473C363.765 306.947 364.991 307.19 366.228 307.19H460.821L457.277 329.817C457.277 329.817 437.025 340.576 451.265 340.892C465.505 341.209 532.593 340.892 532.593 340.892C532.593 340.892 545.567 340.892 524.998 329.5L521.664 307.19H615.414C616.651 307.19 617.877 306.947 619.02 306.473C620.164 306 621.203 305.306 622.078 304.43C622.953 303.555 623.647 302.516 624.121 301.373C624.594 300.23 624.838 299.004 624.838 297.766V129.909C624.838 128.671 624.594 127.446 624.121 126.302C623.647 125.159 622.953 124.12 622.078 123.245C621.203 122.37 620.164 121.675 619.02 121.202C617.877 120.728 616.651 120.485 615.414 120.485Z" fill="#3F3D56"/> </g> <path id="Vector_39" d="M616 130H366V270H616V130Z" fill="#F2F2F2"/> <mask id="mask0"> <path id="Vector_40" d="M616 130H366V270H616V130Z" fill="#F2F2F2"/> </mask> <g mask="url(#mask0)" > <g id="code-main" filter="url(#filter0_d)"> <g id="code-main_2"> <g id="Group15"> <path id="Rectangle59" d="M424.752 164.345H395V171.444H424.752V164.345Z" fill="#6C63FF"/> <path id="Rectangle60" d="M527.784 164.345H517.315V171.444H527.784V164.345Z" fill="#6C63FF"/> <path id="Rectangle61" d="M548.721 164.345H538.252V171.444H548.721V164.345Z" fill="#6C63FF"/> <path id="Rectangle62" d="M506.296 164.345H435.221V171.444H506.296V164.345Z" fill="#6C63FF"/> <path id="Rectangle63" d="M547.619 134.308H517.866V141.408H547.619V134.308Z" fill="#6C63FF"/> <path id="Rectangle64" d="M587.839 134.308H558.087V141.408H587.839V134.308Z" fill="#6C63FF"/> <path id="Rectangle66" d="M405.468 134.308H395V141.408H405.468V134.308Z" fill="#6C63FF"/> <path id="Rectangle67" d="M426.405 134.308H415.937V141.408H426.405V134.308Z" fill="#6C63FF"/> <path id="Rectangle68" d="M507.949 134.308H436.874V141.408H507.949V134.308Z" fill="#6C63FF"/> <path id="Rectangle69" d="M485.91 149.6H456.158V156.699H485.91V149.6Z" fill="#6C63FF"/> <path id="Rectangle70" d="M445.689 149.6H415.937V156.699H445.689V149.6Z" fill="#6C63FF"/> <path id="Rectangle71" d="M405.468 149.6H395V156.699H405.468V149.6Z" fill="#6C63FF"/> <path id="Rectangle73" d="M587.839 149.6H577.371V156.699H587.839V149.6Z" fill="#6C63FF"/> <path id="Rectangle74" d="M566.902 149.6H495.827V156.699H566.902V149.6Z" fill="#6C63FF"/> </g> <use xlink:href="#Group15" y="-45" /> <use xlink:href="#Group15" y="-90" /> <use xlink:href="#Group15" y="-135" /> <use xlink:href="#Group15" y="-180" /> </g> </g> </g> </g> </g> <defs> <filter id="filter0_d" x="391" y="-181" width="200.839" height="360.444" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"> <feFlood flood-opacity="0" result="BackgroundImageFix"/> <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/> <feOffset dy="4"/> <feGaussianBlur stdDeviation="2"/> <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/> <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/> <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/> </filter> <clipPath id="clip0"> <rect width="711.188" height="669.683" fill="white"/> </clipPath> </defs> </svg>
Reveal image on hovered SVG element
Here I've received an answer how to rewrite the skewed div fully with svg. Works perfectly. But I need a special effect, once the skewed div is hovered - reveal the image. Here is a demonstration showing what I want to achieve with alpha channel. And here is my markup with <image> tag and full svg. The problem is that <image> is not revealed and, as I understand, the special attributes, as width & height should be provided into image tag. I want to keep it responsive and everything centered. css .oblique-block g image { opacity: 100%; filter: alpha(opacity=100); height: 100%; z-index: 9999; width: 458px; } .oblique-block a :hover.icon image { z-index: 999; opacity: 0.3; filter: alpha(opacity=30); max-width: none; transition: 0.5s; -moz-transition: 0.5s; -webkit-transition: 0.5s; -o-transition: 0.5s; } .oblique-block { width:100%; height:100%; } .oblique-block text { font-size:14px; font-weight:bold; fill:white; text-anchor:middle; } markup with svg .oblique-block g image { opacity: 100%; filter: alpha(opacity=100); height: 100%; z-index: 9999; width: 458px; } .oblique-block a :hover.icon image { z-index: 999; opacity: 0.3; filter: alpha(opacity=30); max-width: none; transition: 0.5s; -moz-transition: 0.5s; -webkit-transition: 0.5s; -o-transition: 0.5s; } .oblique-block { width:100%; height:100%; } .oblique-block text { font-size:14px; font-weight:bold; fill:white; text-anchor:middle; } <div class="oblique-block"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 671 208" preserveAspectRatio="xMinYMin meet"> <a href="#" title="Meet the creators" target="_self"> <g class="icon"> <path scale(0.8)="" id="p1" fill="#65C6CC" d="M 5,3 H 150 L 120,203 H 5 Z"></path> <!-- icon supervisor --> <path class="icon" fill="white" fill-rule="evenodd" clip-rule="evenodd" d="M15 3.92883C10.4897 3.92883 6.83337 7.58517 6.83337 12.0955C6.83337 16.6058 10.4897 20.2622 15 20.2622C19.5104 20.2622 23.1667 16.6058 23.1667 12.0955C23.1667 7.58517 19.5104 3.92883 15 3.92883ZM9.83337 12.0955C9.83337 9.24203 12.1466 6.92883 15 6.92883C17.8535 6.92883 20.1667 9.24203 20.1667 12.0955C20.1667 14.949 17.8535 17.2622 15 17.2622C12.1466 17.2622 9.83337 14.949 9.83337 12.0955ZM8.33329 23.9288C3.82297 23.9288 0.166626 27.5852 0.166626 32.0955V35.4288C0.166626 36.2573 0.838199 36.9288 1.66663 36.9288C2.49505 36.9288 3.16663 36.2573 3.16663 35.4288V32.0955C3.16663 29.242 5.47982 26.9288 8.33329 26.9288H21.6666C24.5201 26.9288 26.8333 29.242 26.8333 32.0955V35.4288C26.8333 36.2573 27.5049 36.9288 28.3333 36.9288C29.1617 36.9288 29.8333 36.2573 29.8333 35.4288V32.0955C29.8333 27.5852 26.1769 23.9288 21.6666 23.9288H8.33329ZM31.881 25.2705C32.0881 24.4684 32.9063 23.986 33.7084 24.1931C37.3119 25.1236 39.8306 28.3727 39.8334 32.0944V32.0955V35.4288C39.8334 36.2573 39.1618 36.9288 38.3334 36.9288C37.5049 36.9288 36.8334 36.2573 36.8334 35.4288V32.0966V32.0963C36.8315 29.7419 35.2381 27.6865 32.9584 27.0979C32.1563 26.8908 31.6739 26.0726 31.881 25.2705ZM27.0387 4.19238C26.2361 3.9869 25.419 4.47091 25.2135 5.27345C25.008 6.07599 25.492 6.89315 26.2946 7.09863C28.5807 7.68398 30.1797 9.74395 30.1797 12.1038C30.1797 14.4637 28.5807 16.5237 26.2946 17.109C25.492 17.3145 25.008 18.1317 25.2135 18.9342C25.419 19.7368 26.2361 20.2208 27.0387 20.0153C30.6523 19.0901 33.1797 15.834 33.1797 12.1038C33.1797 8.3737 30.6523 5.1176 27.0387 4.19238ZM41.3115 25.2704C41.5187 24.4683 42.3368 23.986 43.1389 24.1931C46.7425 25.1235 49.2611 28.3726 49.2639 32.0943V32.0954V35.4288C49.2639 36.2572 48.5923 36.9288 47.7639 36.9288C46.9355 36.9288 46.2639 36.2572 46.2639 35.4288V32.0966V32.0963C46.262 29.7418 44.6686 27.6864 42.3889 27.0978C41.5868 26.8907 41.1044 26.0726 41.3115 25.2704ZM36.4696 4.19244C35.6671 3.98696 34.8499 4.47097 34.6444 5.27351C34.4389 6.07605 34.9229 6.89321 35.7255 7.09869C38.0116 7.68404 39.6106 9.74402 39.6106 12.1039C39.6106 14.4638 38.0116 16.5238 35.7255 17.1091C34.9229 17.3146 34.4389 18.1318 34.6444 18.9343C34.8499 19.7368 35.6671 20.2208 36.4696 20.0154C40.0832 19.0901 42.6106 15.834 42.6106 12.1039C42.6106 8.37376 40.0832 5.11767 36.4696 4.19244Z" fill-opacity="0.9" transform="scale(0.5) translate(130 130)"></path> <text x="70" y="130"> MEET <tspan x="65" y="150"> THE CREATERS </tspan> </text> </g> <a></a> <a href="#" title="Cars that found homes" target="_self"> <g class="icon"> <image xlink:href="https://picsum.photos/200/300" x="0" y="0"></image> <path id="p2" fill="#E0AD51" d="M 150,3 H 285 L 255,203 H 120 Z"></path> <!-- icon alarm --> <path fill="white" fill-rule="evenodd" clip-rule="evenodd" d="M20 2.25958C9.96681 2.25958 1.83331 10.3931 1.83331 20.4263C1.83331 30.4594 9.96681 38.5929 20 38.5929C30.0332 38.5929 38.1666 30.4594 38.1666 20.4263C38.1666 10.3931 30.0332 2.25958 20 2.25958ZM4.83331 20.4263C4.83331 12.0499 11.6237 5.25958 20 5.25958C28.3763 5.25958 35.1666 12.0499 35.1666 20.4263C35.1666 28.8026 28.3763 35.5929 20 35.5929C11.6237 35.5929 4.83331 28.8026 4.83331 20.4263ZM21.5 10.4263C21.5 9.59784 20.8284 8.92627 20 8.92627C19.1716 8.92627 18.5 9.59784 18.5 10.4263V20.4263C18.5 20.8241 18.658 21.2056 18.9393 21.4869L23.9393 26.4869C24.5251 27.0727 25.4749 27.0727 26.0607 26.4869C26.6464 25.9011 26.6464 24.9514 26.0607 24.3656L21.5 19.8049V10.4263Z" fill-opacity="0.9" transform="scale(0.5) translate(390 130)"></path> <text x="200" y="130"> CARS THAT <tspan x="195" y="150"> FOUND HOMES </tspan> </text> </g> </a> <a href="#" title="Check out the “a”list" target="_self"> <g class="icon"> <image xlink:href="https://picsum.photos/200/300"></image> <path id="p3" fill="#329FA4" d="M 285,3 H 425 L 390,203 H 255 Z"></path> <!-- icon favorite --> <path fill="white" fill-rule="evenodd" clip-rule="evenodd" d="M20.7062 7.06419C22.7067 5.06288 25.4204 3.93848 28.2502 3.93848C31.08 3.93848 33.7939 5.06297 35.7944 7.06444C37.7956 9.06493 38.9199 11.7786 38.9199 14.6082C38.9199 17.4379 37.7955 20.1517 35.7942 22.1522C35.7941 22.1523 35.7943 22.1521 35.7942 22.1522L21.0608 36.8855C20.7795 37.1668 20.398 37.3249 20.0002 37.3249C19.6024 37.3249 19.2208 37.1668 18.9395 36.8855L4.20618 22.1522C0.0397515 17.9857 0.0397522 11.2306 4.20618 7.06419C8.37262 2.89776 15.1277 2.89776 19.2942 7.06419L20.0002 7.7702L20.7062 7.06419C20.7061 7.06428 20.7063 7.06411 20.7062 7.06419ZM28.2502 6.93848C26.2162 6.93848 24.2656 7.74671 22.8277 9.18526L21.0608 10.9522C20.7795 11.2335 20.398 11.3915 20.0002 11.3915C19.6024 11.3915 19.2208 11.2335 18.9395 10.9522L17.1728 9.18551C14.178 6.19065 9.32236 6.19065 6.3275 9.18551C3.33265 12.1804 3.33264 17.036 6.3275 20.0309L20.0002 33.7035L33.6728 20.0309C35.1114 18.593 35.9199 16.6421 35.9199 14.6082C35.9199 12.5742 35.1117 10.6236 33.6731 9.18576C32.2352 7.7472 30.2841 6.93848 28.2502 6.93848Z" fill-opacity="0.9" transform="scale(0.5) translate(660 130)"></path> <text x="330" y="130"> CHECK OUT <tspan x="325" y="150"> THE `A` LIST </tspan> </text> </g> </a> <a href="#" title="Drive into the adventure" target="_self"> <g class="icon"> <image xlink:href="https://picsum.photos/200/300" x="0" y="0"></image> <path id="p4" fill="#E0AD51" d="M 425,3 H 560 L 525,203 H 390 L 425,3"></path> <!-- icon map --> <path transform="translate(460 50)" fill="white" fill-rule="evenodd" clip-rule="evenodd" d="M13.3288 2.26972C13.0498 2.27054 12.7888 2.34752 12.5653 2.48096L0.922479 9.13402C0.455116 9.40108 0.166687 9.8981 0.166687 10.4364V37.1031C0.166687 37.6378 0.451325 38.132 0.913797 38.4004C1.37627 38.6688 1.94664 38.6707 2.4109 38.4054L13.3806 32.137L25.9681 38.4308C26.1767 38.5408 26.4144 38.6031 26.6667 38.6031C26.9474 38.6031 27.21 38.526 27.4347 38.3918L39.0776 31.7387C39.5449 31.4717 39.8334 30.9747 39.8334 30.4364V3.76971C39.8334 3.23501 39.5487 2.74073 39.0862 2.47235C38.6238 2.20397 38.0534 2.20206 37.5891 2.46735L26.6195 8.73573L14.0304 2.44117C13.8256 2.3335 13.5929 2.2718 13.3459 2.26977L13.3333 2.26971L13.3288 2.26972ZM28.1667 34.5183L36.8334 29.5659V6.35448L28.1667 11.3069V34.5183ZM25.1667 11.3634L14.8333 6.19675V29.5093L25.1667 34.676V11.3634ZM3.16669 11.3069L11.8333 6.35451V29.5659L3.16669 34.5183V11.3069Z" fill-opacity="0.9"></path> <path d="M0 0h24v24H0z" fill="none"></path> <text x="470" y="130"> DRIVE INTO <tspan x="465" y="150"> THE ADVENTURE </tspan> </text> </g> </a> <a href="#" title="Get in touch with us" target="_self"> <g class="icon"> <path id="p5" fill="#65C6CC" d="M 560,3 H 670 V 203 H 525 Z"></path> <!-- chat --> <path transform="translate(585 50)" fill="white" fill-rule="evenodd" clip-rule="evenodd" d="M20.8294 6.9467C18.8659 6.94158 16.9289 7.40033 15.1763 8.2856L15.1706 8.28847C10.8798 10.4329 8.16852 14.8171 8.16667 19.614L8.16666 19.6173C8.16154 21.5808 8.6203 23.5178 9.50557 25.2704C9.68588 25.6274 9.71617 26.0416 9.58969 26.421L7.37171 33.075L14.0257 30.857C14.4051 30.7305 14.8193 30.7608 15.1763 30.9411C16.9289 31.8264 18.8659 32.2852 20.8294 32.28L20.8328 32.28C25.6296 32.2782 30.0138 29.5669 32.1582 25.2761L32.1611 25.2704C33.0464 23.5178 33.5051 21.5808 33.5 19.6173L33.5 19.6134V18.8225C33.1269 12.4251 28.0216 7.31974 21.6242 6.9467H20.8333L20.8294 6.9467ZM36.5 19.611C36.5061 22.0455 35.9374 24.447 34.8403 26.6203C32.1877 31.9249 26.7671 35.2769 20.8362 35.28L20.8339 35.28L20.8372 35.28L20.8362 35.28C18.6135 35.2857 16.4182 34.8122 14.3991 33.8948C10.9138 35.0566 5.47434 36.8697 5.47434 36.8697C4.93534 37.0494 4.34109 36.9091 3.93934 36.5074C3.53759 36.1056 3.39731 35.5114 3.57698 34.9724L6.55189 26.0476C5.63459 24.0287 5.16111 21.8336 5.16667 19.6111L5.16667 19.6128L5.16667 19.6095L5.16667 19.6111C5.16959 13.6799 8.52173 8.25896 13.8266 5.60635L13.8237 5.60781L13.8294 5.60495L13.8266 5.60635C15.9997 4.50931 18.401 3.94067 20.8352 3.9467H21.6667C21.6942 3.9467 21.7218 3.94746 21.7493 3.94898C29.7057 4.38793 36.0588 10.741 36.4977 18.6974C36.4992 18.7249 36.5 18.7525 36.5 18.78V19.611Z" fill-opacity="0.9"></path> <text x="605" y="130"> GET IN TOUCH <tspan x="605" y="150"> WITH US </tspan> </text> </g> </a> </a></svg> </div>
I would use only one path :#thePath and I would <use> this path as many times as required. This group can be translated to the needed position . The image stays underneath the <use> element and changes the fill-opacity from one to .7 (for example) Also Y would use #thePath for a <clipPath> element. The image would be clipped by the <clipPath> element: style="clip-path:url(#clip2)" Observation: for the text I'm using pointer-events:none;. This way the .overlay would stay semiopaque when I'm mousing over the text .overlay { fill-opacity: 1; transition: 0.5s; } .overlay:hover { fill-opacity: 0.7; } svg { border: 1px solid; } .oblique-block text { font-size: 14px; font-weight: bold; fill: white; text-anchor: middle; pointer-events:none; } <div class="oblique-block"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 671 208" preserveAspectRatio="xMinYMin meet"> <defs> <clipPath id="clip2"> <path id="thePath" d="M30,3h135l-30,200h-135z"></path> </clipPath> </defs> <g class="icon" transform="translate(120)"> <a href="#" title="Cars that found homes" target="_self"> <image xlink:href="https://picsum.photos/200/300" width="200" x="-16" height="250" style="clip-path:url(#clip2)" ></image> <use class="overlay" xlink:href="#thePath" fill="#E0AD51" fill-opacity="1" /> <!-- icon alarm --> <path fill="white" d="M20 2.25958C9.96681 2.25958 1.83331 10.3931 1.83331 20.4263C1.83331 30.4594 9.96681 38.5929 20 38.5929C30.0332 38.5929 38.1666 30.4594 38.1666 20.4263C38.1666 10.3931 30.0332 2.25958 20 2.25958ZM4.83331 20.4263C4.83331 12.0499 11.6237 5.25958 20 5.25958C28.3763 5.25958 35.1666 12.0499 35.1666 20.4263C35.1666 28.8026 28.3763 35.5929 20 35.5929C11.6237 35.5929 4.83331 28.8026 4.83331 20.4263ZM21.5 10.4263C21.5 9.59784 20.8284 8.92627 20 8.92627C19.1716 8.92627 18.5 9.59784 18.5 10.4263V20.4263C18.5 20.8241 18.658 21.2056 18.9393 21.4869L23.9393 26.4869C24.5251 27.0727 25.4749 27.0727 26.0607 26.4869C26.6464 25.9011 26.6464 24.9514 26.0607 24.3656L21.5 19.8049V10.4263Z" fill-opacity="0.9" transform="scale(0.5) translate(150 130)"></path> <text x="80" y="130"> CARS THAT <tspan x="75" y="150"> FOUND HOMES </tspan> </text> </a> </g> </svg> </div> And here is an example where I'm using the same structure 3 times with different transform translate values and different fill color: .overlay { fill-opacity: 1; transition: 0.5s; } .overlay:hover { fill-opacity: 0.7; } svg { border: 1px solid; } .oblique-block text { font-size: 14px; font-weight: bold; fill: white; text-anchor: middle; pointer-events:none; } <div class="oblique-block"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 671 208" preserveAspectRatio="xMinYMin meet"> <defs> <clipPath id="clip1"> <path id="thePathFirst" d="M 5,3 H 150 L 120,203 H 5 Z"></path> </clipPath> <clipPath id="clip2"> <path id="thePath" d="M30,3h135l-30,200h-135z"></path> </clipPath> <clipPath id="clip3"> <path id="thePathLast" d="M30,3h135v200h-165z"></path> </clipPath> </defs> <g class="icon" transform="translate(0)"> <a href="#" title="Cars that found homes" target="_self"> <image xlink:href="https://picsum.photos/200/300" width="200" x="-16" height="250" style="clip-path:url(#clip1)" ></image> <use xlink:href="#thePathFirst" class="overlay" fill="#65C6CC" /> <!-- icon alarm --> <path fill="white" d="M15 3.92883C10.4897 3.92883 6.83337 7.58517 6.83337 12.0955C6.83337 16.6058 10.4897 20.2622 15 20.2622C19.5104 20.2622 23.1667 16.6058 23.1667 12.0955C23.1667 7.58517 19.5104 3.92883 15 3.92883ZM9.83337 12.0955C9.83337 9.24203 12.1466 6.92883 15 6.92883C17.8535 6.92883 20.1667 9.24203 20.1667 12.0955C20.1667 14.949 17.8535 17.2622 15 17.2622C12.1466 17.2622 9.83337 14.949 9.83337 12.0955ZM8.33329 23.9288C3.82297 23.9288 0.166626 27.5852 0.166626 32.0955V35.4288C0.166626 36.2573 0.838199 36.9288 1.66663 36.9288C2.49505 36.9288 3.16663 36.2573 3.16663 35.4288V32.0955C3.16663 29.242 5.47982 26.9288 8.33329 26.9288H21.6666C24.5201 26.9288 26.8333 29.242 26.8333 32.0955V35.4288C26.8333 36.2573 27.5049 36.9288 28.3333 36.9288C29.1617 36.9288 29.8333 36.2573 29.8333 35.4288V32.0955C29.8333 27.5852 26.1769 23.9288 21.6666 23.9288H8.33329ZM31.881 25.2705C32.0881 24.4684 32.9063 23.986 33.7084 24.1931C37.3119 25.1236 39.8306 28.3727 39.8334 32.0944V32.0955V35.4288C39.8334 36.2573 39.1618 36.9288 38.3334 36.9288C37.5049 36.9288 36.8334 36.2573 36.8334 35.4288V32.0966V32.0963C36.8315 29.7419 35.2381 27.6865 32.9584 27.0979C32.1563 26.8908 31.6739 26.0726 31.881 25.2705ZM27.0387 4.19238C26.2361 3.9869 25.419 4.47091 25.2135 5.27345C25.008 6.07599 25.492 6.89315 26.2946 7.09863C28.5807 7.68398 30.1797 9.74395 30.1797 12.1038C30.1797 14.4637 28.5807 16.5237 26.2946 17.109C25.492 17.3145 25.008 18.1317 25.2135 18.9342C25.419 19.7368 26.2361 20.2208 27.0387 20.0153C30.6523 19.0901 33.1797 15.834 33.1797 12.1038C33.1797 8.3737 30.6523 5.1176 27.0387 4.19238ZM41.3115 25.2704C41.5187 24.4683 42.3368 23.986 43.1389 24.1931C46.7425 25.1235 49.2611 28.3726 49.2639 32.0943V32.0954V35.4288C49.2639 36.2572 48.5923 36.9288 47.7639 36.9288C46.9355 36.9288 46.2639 36.2572 46.2639 35.4288V32.0966V32.0963C46.262 29.7418 44.6686 27.6864 42.3889 27.0978C41.5868 26.8907 41.1044 26.0726 41.3115 25.2704ZM36.4696 4.19244C35.6671 3.98696 34.8499 4.47097 34.6444 5.27351C34.4389 6.07605 34.9229 6.89321 35.7255 7.09869C38.0116 7.68404 39.6106 9.74402 39.6106 12.1039C39.6106 14.4638 38.0116 16.5238 35.7255 17.1091C34.9229 17.3146 34.4389 18.1318 34.6444 18.9343C34.8499 19.7368 35.6671 20.2208 36.4696 20.0154C40.0832 19.0901 42.6106 15.834 42.6106 12.1039C42.6106 8.37376 40.0832 5.11767 36.4696 4.19244Z" fill-opacity="0.9" transform="scale(0.5) translate(150 130)"></path> <text x="80" y="130"> CARS THAT <tspan x="75" y="150"> FOUND HOMES </tspan> </text> </a> </g> <g class="icon" transform="translate(120)"> <a href="#" title="Cars that found homes" target="_self"> <image xlink:href="https://picsum.photos/200/300" width="200" x="-16" height="250" style="clip-path:url(#clip2)" ></image> <use class="overlay" xlink:href="#thePath" fill="#E0AD51" fill-opacity="1" /> <!-- icon alarm --> <path fill="white" d="M20 2.25958C9.96681 2.25958 1.83331 10.3931 1.83331 20.4263C1.83331 30.4594 9.96681 38.5929 20 38.5929C30.0332 38.5929 38.1666 30.4594 38.1666 20.4263C38.1666 10.3931 30.0332 2.25958 20 2.25958ZM4.83331 20.4263C4.83331 12.0499 11.6237 5.25958 20 5.25958C28.3763 5.25958 35.1666 12.0499 35.1666 20.4263C35.1666 28.8026 28.3763 35.5929 20 35.5929C11.6237 35.5929 4.83331 28.8026 4.83331 20.4263ZM21.5 10.4263C21.5 9.59784 20.8284 8.92627 20 8.92627C19.1716 8.92627 18.5 9.59784 18.5 10.4263V20.4263C18.5 20.8241 18.658 21.2056 18.9393 21.4869L23.9393 26.4869C24.5251 27.0727 25.4749 27.0727 26.0607 26.4869C26.6464 25.9011 26.6464 24.9514 26.0607 24.3656L21.5 19.8049V10.4263Z" fill-opacity="0.9" transform="scale(0.5) translate(150 130)"></path> <text x="80" y="130"> CARS THAT <tspan x="75" y="150"> FOUND HOMES </tspan> </text> </a> </g> <g class="icon" transform="translate(255)"> <a href="#" title="Cars that found homes" target="_self"> <image xlink:href="https://picsum.photos/200/300" width="200" x="-16" height="250" style="clip-path:url(#clip2)" ></image> <use class="overlay" xlink:href="#thePath" fill="#65C6CC" fill-opacity="1" /> <!-- icon alarm --> <path fill="white" d="M20.7062 7.06419C22.7067 5.06288 25.4204 3.93848 28.2502 3.93848C31.08 3.93848 33.7939 5.06297 35.7944 7.06444C37.7956 9.06493 38.9199 11.7786 38.9199 14.6082C38.9199 17.4379 37.7955 20.1517 35.7942 22.1522C35.7941 22.1523 35.7943 22.1521 35.7942 22.1522L21.0608 36.8855C20.7795 37.1668 20.398 37.3249 20.0002 37.3249C19.6024 37.3249 19.2208 37.1668 18.9395 36.8855L4.20618 22.1522C0.0397515 17.9857 0.0397522 11.2306 4.20618 7.06419C8.37262 2.89776 15.1277 2.89776 19.2942 7.06419L20.0002 7.7702L20.7062 7.06419C20.7061 7.06428 20.7063 7.06411 20.7062 7.06419ZM28.2502 6.93848C26.2162 6.93848 24.2656 7.74671 22.8277 9.18526L21.0608 10.9522C20.7795 11.2335 20.398 11.3915 20.0002 11.3915C19.6024 11.3915 19.2208 11.2335 18.9395 10.9522L17.1728 9.18551C14.178 6.19065 9.32236 6.19065 6.3275 9.18551C3.33265 12.1804 3.33264 17.036 6.3275 20.0309L20.0002 33.7035L33.6728 20.0309C35.1114 18.593 35.9199 16.6421 35.9199 14.6082C35.9199 12.5742 35.1117 10.6236 33.6731 9.18576C32.2352 7.7472 30.2841 6.93848 28.2502 6.93848Z" fill-opacity="0.9" transform="scale(0.5) translate(150 130)"></path> <text x="80" y="130"> CARS THAT <tspan x="75" y="150"> FOUND HOMES </tspan> </text> </a> </g> <g class="icon" transform="translate(390)"> <a href="#" title="Cars that found homes" target="_self"> <image xlink:href="https://picsum.photos/200/300" width="200" x="-16" height="250" style="clip-path:url(#clip2)" ></image> <use class="overlay" xlink:href="#thePath" fill="#E0AD51" fill-opacity="1" /> <!-- icon alarm --> <path fill="white" d="M13.3288 2.26972C13.0498 2.27054 12.7888 2.34752 12.5653 2.48096L0.922479 9.13402C0.455116 9.40108 0.166687 9.8981 0.166687 10.4364V37.1031C0.166687 37.6378 0.451325 38.132 0.913797 38.4004C1.37627 38.6688 1.94664 38.6707 2.4109 38.4054L13.3806 32.137L25.9681 38.4308C26.1767 38.5408 26.4144 38.6031 26.6667 38.6031C26.9474 38.6031 27.21 38.526 27.4347 38.3918L39.0776 31.7387C39.5449 31.4717 39.8334 30.9747 39.8334 30.4364V3.76971C39.8334 3.23501 39.5487 2.74073 39.0862 2.47235C38.6238 2.20397 38.0534 2.20206 37.5891 2.46735L26.6195 8.73573L14.0304 2.44117C13.8256 2.3335 13.5929 2.2718 13.3459 2.26977L13.3333 2.26971L13.3288 2.26972ZM28.1667 34.5183L36.8334 29.5659V6.35448L28.1667 11.3069V34.5183ZM25.1667 11.3634L14.8333 6.19675V29.5093L25.1667 34.676V11.3634ZM3.16669 11.3069L11.8333 6.35451V29.5659L3.16669 34.5183V11.3069Z" fill-opacity="0.9" transform="scale(0.5) translate(150 130)"></path> <text x="80" y="130"> CARS THAT <tspan x="75" y="150"> FOUND HOMES </tspan> </text> </a> </g> <g class="icon" transform="translate(525)"> <a href="#" title="Cars that found homes" target="_self"> <image xlink:href="https://picsum.photos/200/300" width="200" x="-16" height="250" style="clip-path:url(#clip3)" ></image> <use xlink:href="#thePathLast" class="overlay" fill="#65C6CC" /> <!-- icon alarm --> <path fill="white" d="M20.8294 6.9467C18.8659 6.94158 16.9289 7.40033 15.1763 8.2856L15.1706 8.28847C10.8798 10.4329 8.16852 14.8171 8.16667 19.614L8.16666 19.6173C8.16154 21.5808 8.6203 23.5178 9.50557 25.2704C9.68588 25.6274 9.71617 26.0416 9.58969 26.421L7.37171 33.075L14.0257 30.857C14.4051 30.7305 14.8193 30.7608 15.1763 30.9411C16.9289 31.8264 18.8659 32.2852 20.8294 32.28L20.8328 32.28C25.6296 32.2782 30.0138 29.5669 32.1582 25.2761L32.1611 25.2704C33.0464 23.5178 33.5051 21.5808 33.5 19.6173L33.5 19.6134V18.8225C33.1269 12.4251 28.0216 7.31974 21.6242 6.9467H20.8333L20.8294 6.9467ZM36.5 19.611C36.5061 22.0455 35.9374 24.447 34.8403 26.6203C32.1877 31.9249 26.7671 35.2769 20.8362 35.28L20.8339 35.28L20.8372 35.28L20.8362 35.28C18.6135 35.2857 16.4182 34.8122 14.3991 33.8948C10.9138 35.0566 5.47434 36.8697 5.47434 36.8697C4.93534 37.0494 4.34109 36.9091 3.93934 36.5074C3.53759 36.1056 3.39731 35.5114 3.57698 34.9724L6.55189 26.0476C5.63459 24.0287 5.16111 21.8336 5.16667 19.6111L5.16667 19.6128L5.16667 19.6095L5.16667 19.6111C5.16959 13.6799 8.52173 8.25896 13.8266 5.60635L13.8237 5.60781L13.8294 5.60495L13.8266 5.60635C15.9997 4.50931 18.401 3.94067 20.8352 3.9467H21.6667C21.6942 3.9467 21.7218 3.94746 21.7493 3.94898C29.7057 4.38793 36.0588 10.741 36.4977 18.6974C36.4992 18.7249 36.5 18.7525 36.5 18.78V19.611Z" fill-opacity="0.9" transform="scale(0.5) translate(150 130)"></path> <text x="80" y="130"> CARS THAT <tspan x="75" y="150"> FOUND HOMES </tspan> </text> </a> </g> </svg> </div>
Forcing an SVG to resize based on percentage height
I have a footer containing a row of scaling SVG buttons that I am very happy with except for one thing: I cannot get the height of the svgs to scale to be a certain percentage of their container (e.g. 30%) in my footer. I have tried for days but I cannot figure out why. If I use a fixed size (in pixels, for example), the height sort of does what I want, but it isn't responsive in the way I'd like. Maybe I don't yet understand something about svgs. I would really like the svg div to be based on a relative percentage of the height of its container. Thanks in advance! This is the codepen: http://codepen.io/ihatecoding/pen/KzRQWO This is the snippet: #footer { text-align: center; position: fixed; vertical-align: middle; bottom: 0; left: 0; z-index: 5000; width: 100%; max-height:40% !important; } .areaSVG { width: auto; /* this is the height setting I would like to be a percentage */ height: 60px; /* <------ there*/ overflow: visible; margin: 0 26% 0 26%; box-sizing: content-box; backgroud-color: Grey; } .ey-col-svg { display: block; margin: 10% 20% 10% 20%; text-align: center; background-color: Red; } .ey-nav-bar { background-color: MediumVioletRed ! important; width: 100% !important; overflow: hidden; text-align: center; height: auto; } .ey-row-scale { text-align: center; padding-left: 5%; padding-right: 5%; display: block; background-color: Orange; max-width: 90%; overflow: hidden; } .ey-col-1 { text-align: center; background-color: Green; width: 24%; margin: 0; padding: 0; display: inline-block; border-collapse: collapse; } .ey-text-content { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; display: block; text-align: center; white-space: nowrap; font-size: 2vw; color: black; z-index: 10000; } #linkTextCell { text-align: center; width: 100%; vertical-align: middle; font-size: 150%; display: block; color: White; background-color: Blue; } #content {font-size: 2vw;} <div id="content"> <p>I am happy with this row of scaling svgs, except for one thing - I want the height of the svgs (class "areaSVG" ) to be fixed 30%, but I can't get it to stick. It sort of behaves as I wnat if I set a fixed pixel, but I would really love it if the height could be percentage based. If you know about svgs, perhaps you can figure out a way to do this?</p> </div> <div id="footer"> <div id="linkTextCell" class="navText hideRow"> Links: </div> <div class="ey-nav-bar"> <div class="ey-row-scale"> <div class="ey-col-1"> <a class = "eSVG areaAnchor" href="#"> <div class="ey-col-svg"> <svg class="areaSVG" viewBox="20 0 37 73" preserveAspectRatio="xMidYMin slice" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <path id="circle-background" opacity="0.4196" fill="#FFFFFF" enable-background="new " d=" M4.193,37.492c0-18.987,15.419-34.38,34.44-34.38c19.021,0,34.439,15.393,34.439,34.38c0,18.987-15.418,34.381-34.439,34.381 C19.613,71.873,4.193,56.48,4.193,37.492L4.193,37.492z" /> <path id="sclera" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M11.41,38.895c27.619-31.029,41.313-9.542,49.646-2.012c-4.306,6.07-12.69,27.49-46.392,9.919c0,0-5.375-3.548-5.641-4.75 C12.787,37.379,11.41,38.895,11.41,38.895z" /> <ellipse id="iris" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" cx="38.196" cy="36.63" rx="16.202" ry="15.686" /> <ellipse id="pupil" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" cx="38.529" cy="36.954" rx="5.628" ry="5.449" /> <path id="eyelid" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M56.955,26.227c5.438,2.787,12.803,9.595,12.803,9.595s-2.338,3.235-5.677,2.588c-4.027,3.396-13.345,29.705-49.417,8.393 c33.702,17.571,42.086-3.849,46.392-9.919c-8.333-7.53-22.026-29.018-49.646,2.012c0,0-2.94,1.806-4.112-1.456 c-1.172-3.261,2.481-0.477,4.009-2.911c1.527-2.434,3.674-3.557,7.682-6.792c-4.008,0.646-7.348,3.558-7.348,3.558 c10.521-10.835,31.379-17.498,53.107-4.205C64.748,27.089,59.404,26.119,56.955,26.227z" /> </svg> </div> <div class="ey-text-content navText">Link 1</div> </a> </div> <div class="ey-col-1"> <a class = "sSVG areaAnchor" href="#"> <div class="ey-col-svg"> <svg class="areaSVG" viewBox="20 0 37 73" preserveAspectRatio="xMidYMin slice" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <path id="circle-background" opacity="0.4196" fill="#FFFFFF" enable-background="new " d=" M4.193,37.492c0-18.987,15.419-34.38,34.44-34.38c19.021,0,34.439,15.393,34.439,34.38c0,18.987-15.418,34.381-34.439,34.381 C19.613,71.873,4.193,56.48,4.193,37.492L4.193,37.492z" /> <path id="sclera" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M11.41,38.895c27.619-31.029,41.313-9.542,49.646-2.012c-4.306,6.07-12.69,27.49-46.392,9.919c0,0-5.375-3.548-5.641-4.75 C12.787,37.379,11.41,38.895,11.41,38.895z" /> <ellipse id="iris" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" cx="38.196" cy="36.63" rx="16.202" ry="15.686" /> <ellipse id="pupil" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" cx="38.529" cy="36.954" rx="5.628" ry="5.449" /> <path id="eyelid" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M56.955,26.227c5.438,2.787,12.803,9.595,12.803,9.595s-2.338,3.235-5.677,2.588c-4.027,3.396-13.345,29.705-49.417,8.393 c33.702,17.571,42.086-3.849,46.392-9.919c-8.333-7.53-22.026-29.018-49.646,2.012c0,0-2.94,1.806-4.112-1.456 c-1.172-3.261,2.481-0.477,4.009-2.911c1.527-2.434,3.674-3.557,7.682-6.792c-4.008,0.646-7.348,3.558-7.348,3.558 c10.521-10.835,31.379-17.498,53.107-4.205C64.748,27.089,59.404,26.119,56.955,26.227z" /> </svg> </div> <div class="ey-text-content navText">Link 2</div> </a> </div> <a class = "wSVG areaAnchor" href="#"> <div class="ey-col-1"> <div class="ey-col-svg"> <svg class="areaSVG" viewBox="20 0 37 73" preserveAspectRatio="xMidYMin slice" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <path id="circle-background" opacity="0.4196" fill="#FFFFFF" enable-background="new " d=" M4.193,37.492c0-18.987,15.419-34.38,34.44-34.38c19.021,0,34.439,15.393,34.439,34.38c0,18.987-15.418,34.381-34.439,34.381 C19.613,71.873,4.193,56.48,4.193,37.492L4.193,37.492z" /> <path id="sclera" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M11.41,38.895c27.619-31.029,41.313-9.542,49.646-2.012c-4.306,6.07-12.69,27.49-46.392,9.919c0,0-5.375-3.548-5.641-4.75 C12.787,37.379,11.41,38.895,11.41,38.895z" /> <ellipse id="iris" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" cx="38.196" cy="36.63" rx="16.202" ry="15.686" /> <ellipse id="pupil" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" cx="38.529" cy="36.954" rx="5.628" ry="5.449" /> <path id="eyelid" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M56.955,26.227c5.438,2.787,12.803,9.595,12.803,9.595s-2.338,3.235-5.677,2.588c-4.027,3.396-13.345,29.705-49.417,8.393 c33.702,17.571,42.086-3.849,46.392-9.919c-8.333-7.53-22.026-29.018-49.646,2.012c0,0-2.94,1.806-4.112-1.456 c-1.172-3.261,2.481-0.477,4.009-2.911c1.527-2.434,3.674-3.557,7.682-6.792c-4.008,0.646-7.348,3.558-7.348,3.558 c10.521-10.835,31.379-17.498,53.107-4.205C64.748,27.089,59.404,26.119,56.955,26.227z" /> </svg> </div> <div class="ey-text-content navText">Link 3</div> </div> </a> <div class="ey-col-1"> <a class = "nSVG areaAnchor" href="#"> <div class="ey-col-svg"> <svg class="areaSVG" viewBox="20 0 37 73" preserveAspectRatio="xMidYMin slice" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <path id="circle-background" opacity="0.4196" fill="#FFFFFF" enable-background="new " d=" M4.193,37.492c0-18.987,15.419-34.38,34.44-34.38c19.021,0,34.439,15.393,34.439,34.38c0,18.987-15.418,34.381-34.439,34.381 C19.613,71.873,4.193,56.48,4.193,37.492L4.193,37.492z" /> <path id="sclera" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M11.41,38.895c27.619-31.029,41.313-9.542,49.646-2.012c-4.306,6.07-12.69,27.49-46.392,9.919c0,0-5.375-3.548-5.641-4.75 C12.787,37.379,11.41,38.895,11.41,38.895z" /> <ellipse id="iris" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" cx="38.196" cy="36.63" rx="16.202" ry="15.686" /> <ellipse id="pupil" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" cx="38.529" cy="36.954" rx="5.628" ry="5.449" /> <path id="eyelid" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M56.955,26.227c5.438,2.787,12.803,9.595,12.803,9.595s-2.338,3.235-5.677,2.588c-4.027,3.396-13.345,29.705-49.417,8.393 c33.702,17.571,42.086-3.849,46.392-9.919c-8.333-7.53-22.026-29.018-49.646,2.012c0,0-2.94,1.806-4.112-1.456 c-1.172-3.261,2.481-0.477,4.009-2.911c1.527-2.434,3.674-3.557,7.682-6.792c-4.008,0.646-7.348,3.558-7.348,3.558 c10.521-10.835,31.379-17.498,53.107-4.205C64.748,27.089,59.404,26.119,56.955,26.227z" /> </svg> </div> <div class="ey-text-content navText">Link 4</div> </a> </div> </div> </div> </div>
When you set an SVG to height: 30%, that means 30% of its parent's height. That parent is a <div> with no explicit height. The <div> gets it's height from its children. It's only child is the SVG. So the browser has no solid information to go on in which to determine what a height of "30%" should actually mean. In order to get "30%" to work, something is going to have to be set to some fixed or deducible height.
To clarify Paul LeBeau's answer: Your SVG is set to height: 30%, which means "30% of the parent div". The parent div is <div class="ey-col-svg">. The css definition for .ey-col-svg does not contain a height statement. If you add height: 100% to the css for .ey-col.svg, then your SVG will fill 30% of the height of its parent div, as per the CSS rule. No Javascript needed.
With a lot of help, I was able make this javascript solution. I hope this helps anyone who wants to get a row of svgs that are fully responsive to the height and width of the screen. Note that because the text in the footer containing the SVGs is not completely responsive to height, the svgs disappear at the smallest media heights. If you want it fully responsive, you should make the text divs height-dependent. Here is the codepen: http://codepen.io/ihatecoding/pen/vGrVQd Here is the snippet: $(document).ready(scaleSVG); $(window).on('resize', scaleSVG); function scaleSVG() { var scale = 0.9; var $eyCol = $(".ey-col-svg"); var eyWidth = $eyCol.width(); var eyHeight = $eyCol.height(); var maxHeight = .4 * $(window).height(); if(eyHeight < eyWidth && eyHeight < maxHeight) $(".areaSVG").height(maxHeight); var imageWidth = scale * $eyCol.width(); var imageHeight = $eyCol.height(); var tot = imageWidth > imageHeight ? imageHeight : imageWidth; //var imageHeight = 0.5*$(".ey-col-svg").height(); $(".areaSVG").css("width", tot); $(".areaSVG").css("height", tot); }; #footer { text-align: center; position: fixed; vertical-align: middle; bottom: 0; left: 0; z-index: 5000; width: 100%; max-height: 40vh; } .areaSVG { /* this is the height setting I wanted to be a percentage */ /*height: 30%; <------ there*/ overflow: visible; box-sizing: content-box; backgroud-color: Grey; } .ey-col-svg { display: block; height: calc(100% - 30px); max-height: calc(40vh - 2vw - 63px); padding: 0 0; margin:0; text-align: center; background-color: Red; } .ey-nav-bar { background-color: MediumVioletRed ! important; width: 100% !important; height: 100%; overflow: hidden; text-align: center; } .ey-row-scale { text-align: center; padding-left: 2.5%; padding-right: 2.5%; display: block; background-color: Orange; max-width: 95%; height: calc(100% - 28px); overflow: hidden; } .ey-col-1 { text-align: center; background-color: Green; width: 20%; height: 100%; margin: 0; padding: 0; display: inline-block; border-collapse: collapse; } .ey-text-content { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; display: block; text-align: center; white-space: nowrap; font-size: 2vw; height: calc(2vw + 5px); line-height: calc(2vw + 5px); color: black; z-index: 10000; } #linkTextCell { text-align: center; width: 100%; height: 28px; line-height: 28px; vertical-align: middle; font-size: 150%; display: block; color: White; background-color: Blue; } #content { font-size: 2vw; } .fillDark{fill:DimGray;} .fillWhite{fill:White;} .strokeDark{stroke:DimGray;} .strokeWhite{stroke:White;} <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script> <div id="content"> <p>Javascript solution to scaling svgs. This isn't perfect. At the very smallest heights the SVGs disappear (because the text isn't scaling in response to hight). But, with a bit of work you can customize this to your needs.</p> </div> <div id="footer"> <div id="linkTextCell" class="navText hideRow"> Links: </div> <div class="ey-nav-bar"> <div class="ey-row-scale"> <div class="ey-col-1"> <a class = "eSVG areaAnchor" href="#"> <div class="ey-col-svg"> <svg class="areaSVG" viewBox="20 0 37 73" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <path id="circle-background" opacity="0.4196" fill="#FFFFFF" enable-background="new " d=" M4.193,37.492c0-18.987,15.419-34.38,34.44-34.38c19.021,0,34.439,15.393,34.439,34.38c0,18.987-15.418,34.381-34.439,34.381 C19.613,71.873,4.193,56.48,4.193,37.492L4.193,37.492z" /> <path id="sclera" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M11.41,38.895c27.619-31.029,41.313-9.542,49.646-2.012c-4.306,6.07-12.69,27.49-46.392,9.919c0,0-5.375-3.548-5.641-4.75 C12.787,37.379,11.41,38.895,11.41,38.895z" /> <ellipse id="iris" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" cx="38.196" cy="36.63" rx="16.202" ry="15.686" /> <ellipse id="pupil" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" cx="38.529" cy="36.954" rx="5.628" ry="5.449" /> <path id="eyelid" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M56.955,26.227c5.438,2.787,12.803,9.595,12.803,9.595s-2.338,3.235-5.677,2.588c-4.027,3.396-13.345,29.705-49.417,8.393 c33.702,17.571,42.086-3.849,46.392-9.919c-8.333-7.53-22.026-29.018-49.646,2.012c0,0-2.94,1.806-4.112-1.456 c-1.172-3.261,2.481-0.477,4.009-2.911c1.527-2.434,3.674-3.557,7.682-6.792c-4.008,0.646-7.348,3.558-7.348,3.558 c10.521-10.835,31.379-17.498,53.107-4.205C64.748,27.089,59.404,26.119,56.955,26.227z" /> </svg> </div> <div class="ey-text-content navText">Link 1</div> </a> </div> <div class="ey-col-1"> <a class = "sSVG areaAnchor" href="#"> <div class="ey-col-svg"> <svg class="areaSVG" viewBox="20 0 37 73" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <path id="circle-background" opacity="0.4196" fill="#FFFFFF" enable-background="new " d=" M4.193,37.492c0-18.987,15.419-34.38,34.44-34.38c19.021,0,34.439,15.393,34.439,34.38c0,18.987-15.418,34.381-34.439,34.381 C19.613,71.873,4.193,56.48,4.193,37.492L4.193,37.492z" /> <path id="sclera" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M11.41,38.895c27.619-31.029,41.313-9.542,49.646-2.012c-4.306,6.07-12.69,27.49-46.392,9.919c0,0-5.375-3.548-5.641-4.75 C12.787,37.379,11.41,38.895,11.41,38.895z" /> <ellipse id="iris" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" cx="38.196" cy="36.63" rx="16.202" ry="15.686" /> <ellipse id="pupil" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" cx="38.529" cy="36.954" rx="5.628" ry="5.449" /> <path id="eyelid" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M56.955,26.227c5.438,2.787,12.803,9.595,12.803,9.595s-2.338,3.235-5.677,2.588c-4.027,3.396-13.345,29.705-49.417,8.393 c33.702,17.571,42.086-3.849,46.392-9.919c-8.333-7.53-22.026-29.018-49.646,2.012c0,0-2.94,1.806-4.112-1.456 c-1.172-3.261,2.481-0.477,4.009-2.911c1.527-2.434,3.674-3.557,7.682-6.792c-4.008,0.646-7.348,3.558-7.348,3.558 c10.521-10.835,31.379-17.498,53.107-4.205C64.748,27.089,59.404,26.119,56.955,26.227z" /> </svg> </div> <div class="ey-text-content navText">Link 2</div> </a> </div> <a class = "wSVG areaAnchor" href="#"> <div class="ey-col-1"> <div class="ey-col-svg"> <svg class="areaSVG" viewBox="20 0 37 73" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <path id="circle-background" opacity="0.4196" fill="#FFFFFF" enable-background="new " d=" M4.193,37.492c0-18.987,15.419-34.38,34.44-34.38c19.021,0,34.439,15.393,34.439,34.38c0,18.987-15.418,34.381-34.439,34.381 C19.613,71.873,4.193,56.48,4.193,37.492L4.193,37.492z" /> <path id="sclera" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M11.41,38.895c27.619-31.029,41.313-9.542,49.646-2.012c-4.306,6.07-12.69,27.49-46.392,9.919c0,0-5.375-3.548-5.641-4.75 C12.787,37.379,11.41,38.895,11.41,38.895z" /> <ellipse id="iris" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" cx="38.196" cy="36.63" rx="16.202" ry="15.686" /> <ellipse id="pupil" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" cx="38.529" cy="36.954" rx="5.628" ry="5.449" /> <path id="eyelid" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M56.955,26.227c5.438,2.787,12.803,9.595,12.803,9.595s-2.338,3.235-5.677,2.588c-4.027,3.396-13.345,29.705-49.417,8.393 c33.702,17.571,42.086-3.849,46.392-9.919c-8.333-7.53-22.026-29.018-49.646,2.012c0,0-2.94,1.806-4.112-1.456 c-1.172-3.261,2.481-0.477,4.009-2.911c1.527-2.434,3.674-3.557,7.682-6.792c-4.008,0.646-7.348,3.558-7.348,3.558 c10.521-10.835,31.379-17.498,53.107-4.205C64.748,27.089,59.404,26.119,56.955,26.227z" /> </svg> </div> <div class="ey-text-content navText">Link 3</div> </div> </a> <div class="ey-col-1"> <a class = "nSVG areaAnchor" href="#"> <div class="ey-col-svg"> <svg class="areaSVG" viewBox="20 0 37 73" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <path id="circle-background" opacity="0.4196" fill="#FFFFFF" enable-background="new " d=" M4.193,37.492c0-18.987,15.419-34.38,34.44-34.38c19.021,0,34.439,15.393,34.439,34.38c0,18.987-15.418,34.381-34.439,34.381 C19.613,71.873,4.193,56.48,4.193,37.492L4.193,37.492z" /> <path id="sclera" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M11.41,38.895c27.619-31.029,41.313-9.542,49.646-2.012c-4.306,6.07-12.69,27.49-46.392,9.919c0,0-5.375-3.548-5.641-4.75 C12.787,37.379,11.41,38.895,11.41,38.895z" /> <ellipse id="iris" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" cx="38.196" cy="36.63" rx="16.202" ry="15.686" /> <ellipse id="pupil" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" cx="38.529" cy="36.954" rx="5.628" ry="5.449" /> <path id="eyelid" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d=" M56.955,26.227c5.438,2.787,12.803,9.595,12.803,9.595s-2.338,3.235-5.677,2.588c-4.027,3.396-13.345,29.705-49.417,8.393 c33.702,17.571,42.086-3.849,46.392-9.919c-8.333-7.53-22.026-29.018-49.646,2.012c0,0-2.94,1.806-4.112-1.456 c-1.172-3.261,2.481-0.477,4.009-2.911c1.527-2.434,3.674-3.557,7.682-6.792c-4.008,0.646-7.348,3.558-7.348,3.558 c10.521-10.835,31.379-17.498,53.107-4.205C64.748,27.089,59.404,26.119,56.955,26.227z" /> </svg> </div> <div class="ey-text-content navText">Link 4</div> </a> </div> </div> </div> </div>