How to hide svg element - html

I have a problem with hiding svg element. Maybe display: none or visibility? I tried but it hasn't any results. As here (IMAGE). Please help.
This is my site with example text "KAWAŁY":
#kawaly-div {
text-align: center;
background: #fda9a9;
}
.link {
text-decoration: none;
position: relative;
line-height: 1;
color: #9e9ba4;
display: inline-block;
}
.link--kawaly {
font-family: 'Oswald', sans-serif;
font-size: 10em;
color: #e78383;
-webkit-transition: color 0s 0.5s;
transition: color 0s 0.5s;
}
.link--kawaly:hover {
color: transparent;
-webkit-transition: none;
transition: none;
}
.link--kawaly::before,
.link--kawaly::after {
content: attr(data-letters);
position: absolute;
top: 0;
left: 0;
color: #e78383;
overflow: hidden;
-webkit-backface-visibility: hidden;
-webkit-transition: color 0.5s, -webkit-transform 0.5s;
transition: color 0.5s, transform 0.5s;
}
.link--kawaly::before {
-webkit-clip-path: url(#cp_up);
clip-path: url(../index.html#cp_up);
}
.link--kawaly::after {
-webkit-clip-path: url(#cp_down);
clip-path: url(../index.html#cp_down);
}
.link--kawaly:hover::before,
.link--kawaly:hover::after {
color: #fff;
-webkit-transition: color 0.5s, -webkit-transform 0.5s;
transition: color 0.5s, transform 0.5s;
}
.link--kawaly:hover::before {
-webkit-transform: translate3d(20px, 1px, 0);
transform: translate3d(20px, 1px, 0);
}
.link--kawaly:hover::after {
-webkit-transform: translate3d(-10px, -1px, 0);
transform: translate3d(-10px, -1px, 0);
}
<link href='http://fonts.googleapis.com/css?family=Raleway:400,500,700,900|Dosis:800|Playfair+Display:400,400italic,900italic|Lora:700|Syncopate:700|Roboto+Condensed:300italic|Oswald:700' rel='stylesheet' type='text/css'>
<div id="kawaly-div">
<svg class="kawaly-tekst">
<clippath id="cp_up">
<polygon id="cp_poly_up" points="0,0 550,0 550,160" />
</clippath>
<clippath id="cp_down">
<polygon id="cp_poly_down" points="0,0 550,160 0,160" />
</clippath>
</svg>
<div class=" color-5">
<a class="link link--kawaly" href="#" data-letters="KAWAŁY">KAWAŁY</a>
</div>
</div>
Thanks in advience!

The most-often recommended way is:
<svg class="kawaly-tekst" width="0" height="0">

Related

How To Keep the Arrow Pointing Up When the Dropdown Is Visible?

I need help. I have a main button that has an arrow pointing down to indicate that there is a dropdown. Upon hover, the dropdown appears and the arrow rotates and pointing up. However, it should keep pointing up when I hover over the dropdown items. Could anyone help me with my codes? Thank you in advance.
Please see the link for codes on CodePen.
https://codepen.io/denzdoneza/pen/ZEjddQp
HTML:
<a href="#" class="mainButton">
<button>Resources<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 24 14.1" style="enable-background:new 0 0 24 14.1;" xml:space="preserve">
<path d="M12,14.1L0,2.1L2.1,0L12,9.9L21.8,0L24,2.2L12,14.1z"/>
</svg></button>
</a>
<div class="dropdown">
<button>Blackpaper</button>
<button>Whitepaper</button>
</div>
CSS:
button {
width: 256px;
height: 52px;
font-size: 16px;
background-color: #cd0d0d;
color: #ffffff;
}
a button svg {
fill: #ffffff;
position: absolute;
width: 12px;
margin: 6px 0 0 8px;
transform: rotate(0deg) translateX(0px) translateY(0px);
transition: transform 0.2s linear;
}
.dropdown {
display: none;
}
button:hover {
background-color: #8e0000;
}
a.mainButton:hover ~ .dropdown {
display: flex;
flex-direction: column;
}
a.mainButton:hover svg {
transform: rotate(180deg) translateX(0px) translateY(0px);
transition: transform 0.2s linear;
}
.dropdown:hover {
display: flex;
flex-direction: column;
}
.dropdown:hover ~ a.mainButton button svg {
transform: rotate(180deg) translateX(0px) translateY(0px) !important;
transition: transform 0.2s linear;
}
I tried a CSS :hover on the container of the dropdown and use ~ to point on the arrow but it didn't work.
CSS:
.dropdown:hover ~ a.mainButton button svg {
transform: rotate(180deg) translateX(0px) translateY(0px) !important;
transition: transform 0.2s linear;
}
You could just put all the code inside a container and then change:
a.mainButton:hover svg {
transform: rotate(180deg) translateX(0px) translateY(0px);
transition: transform 0.2s linear;
}
For:
.container:hover svg {
transform: rotate(180deg) translateX(0px) translateY(0px);
transition: transform 0.2s linear;
}
button {
width: 256px;
height: 52px;
font-size: 16px;
background-color: #cd0d0d;
color: #ffffff;
}
a button svg {
fill: #ffffff;
position: absolute;
width: 12px;
margin: 6px 0 0 8px;
transform: rotate(0deg) translateX(0px) translateY(0px);
transition: transform 0.2s linear;
}
.dropdown {
display: none;
}
a.mainButton:hover ~ .dropdown {
display: flex;
flex-direction: column;
}
.container:hover svg {
transform: rotate(180deg) translateX(0px) translateY(0px);
transition: transform 0.2s linear;
}
.dropdown:hover {
display: flex;
flex-direction: column;
}
.dropdown a:hover ~ a.mainButton button svg {
transform: rotate(180deg) translateX(0px) translateY(0px) !important;
transition: transform 0.2s linear;
}
<div class="container">
<a href="#" class="mainButton">
<button>Resources<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 24 14.1" style="enable-background:new 0 0 24 14.1;" xml:space="preserve">
<path d="M12,14.1L0,2.1L2.1,0L12,9.9L21.8,0L24,2.2L12,14.1z"/>
</svg></button>
</a>
<div class="dropdown">
<button>Blackpaper</button>
<button>Whitepaper</button>
</div>
</div>
You need to add the CSS rule "pointer-events: none" under the display: none; line
.dropdown {
display: none;
pointer-events: none;
}

Why does "<use xlink:href..." change the behavior of an svg image?

I am studying the following code:
* {
box-sizing: border-box;
}
body {
font-family: "Open Sans", sans-serif;
font-size: 16px;
-webkit-font-smoothing: antialiased;
text-rendering: optimizelegibility;
color: #223254;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.cbx {
-webkit-user-select: none;
user-select: none;
cursor: pointer;
padding: 6px 8px;
border-radius: 6px;
overflow: hidden;
transition: all 0.2s ease;
}
.cbx:not(:last-child) {
margin-right: 6px;
}
.cbx:hover {
background: rgba(0, 119, 255, 0.06);
}
.cbx span {
float: left;
vertical-align: middle;
transform: translate3d(0, 0, 0);
}
.cbx span:first-child {
position: relative;
width: 18px;
height: 18px;
border-radius: 4px;
transform: scale(1);
border: 1px solid #cccfdb;
transition: all 0.2s ease;
box-shadow: 0 1px 1px rgba(0, 16, 75, 0.05);
}
.cbx span:first-child svg {
position: absolute;
top: 3px;
left: 2px;
fill: none;
stroke: #fff;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 16px;
stroke-dashoffset: 16px;
transition: all 0.3s ease;
transition-delay: 0.1s;
transform: translate3d(0, 0, 0);
}
.cbx span:last-child {
padding-left: 8px;
line-height: 18px;
}
.cbx:hover span:first-child {
border-color: #07f;
}
.inp-cbx {
position: absolute;
visibility: hidden;
}
.inp-cbx:checked+.cbx span:first-child {
background: #07f;
border-color: #07f;
animation: wave 0.4s ease;
}
.inp-cbx:checked+.cbx span:first-child svg {
stroke-dashoffset: 0;
}
.inline-svg {
position: absolute;
width: 0;
height: 0;
pointer-events: none;
user-select: none;
}
#-moz-keyframes wave {
50% {
transform: scale(0.9);
}
}
#-webkit-keyframes wave {
50% {
transform: scale(0.9);
}
}
#-o-keyframes wave {
50% {
transform: scale(0.9);
}
}
#keyframes wave {
50% {
transform: scale(0.9);
}
}
<input class="inp-cbx" id="morning" type="checkbox" />
<label class="cbx" for="morning">
<span>
<svg width="12px" height="10px">
<use xlink:href="#check"></use>
</svg>
</span>
<span>Label</span>
</label>
<!--SVG Sprite-->
<svg class="inline-svg">
<symbol id="check" viewbox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</symbol>
</svg>
And when I extract the separate svg and put it directly in the svg tag (but removing the inline-svg class), the check svg no longer shows up. As shown here:
* {
box-sizing: border-box;
}
body {
font-family: "Open Sans", sans-serif;
font-size: 16px;
-webkit-font-smoothing: antialiased;
text-rendering: optimizelegibility;
color: #223254;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.cbx {
-webkit-user-select: none;
user-select: none;
cursor: pointer;
padding: 6px 8px;
border-radius: 6px;
overflow: hidden;
transition: all 0.2s ease;
}
.cbx:not(:last-child) {
margin-right: 6px;
}
.cbx:hover {
background: rgba(0, 119, 255, 0.06);
}
.cbx span {
float: left;
vertical-align: middle;
transform: translate3d(0, 0, 0);
}
.cbx span:first-child {
position: relative;
width: 18px;
height: 18px;
border-radius: 4px;
transform: scale(1);
border: 1px solid #cccfdb;
transition: all 0.2s ease;
box-shadow: 0 1px 1px rgba(0, 16, 75, 0.05);
}
.cbx span:first-child svg {
position: absolute;
top: 3px;
left: 2px;
fill: none;
stroke: #fff;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 16px;
stroke-dashoffset: 16px;
transition: all 0.3s ease;
transition-delay: 0.1s;
transform: translate3d(0, 0, 0);
}
.cbx span:last-child {
padding-left: 8px;
line-height: 18px;
}
.cbx:hover span:first-child {
border-color: #07f;
}
.inp-cbx {
position: absolute;
visibility: hidden;
}
.inp-cbx:checked+.cbx span:first-child {
background: #07f;
border-color: #07f;
animation: wave 0.4s ease;
}
.inp-cbx:checked+.cbx span:first-child svg {
stroke-dashoffset: 0;
}
.inline-svg {
position: absolute;
width: 0;
height: 0;
pointer-events: none;
user-select: none;
}
#-moz-keyframes wave {
50% {
transform: scale(0.9);
}
}
#-webkit-keyframes wave {
50% {
transform: scale(0.9);
}
}
#-o-keyframes wave {
50% {
transform: scale(0.9);
}
}
#keyframes wave {
50% {
transform: scale(0.9);
}
}
<input class="inp-cbx" id="morning" type="checkbox" />
<label class="cbx" for="morning">
<span>
<svg width="12px" height="10px">
<symbol id="check" viewbox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</symbol>
</svg>
</span>
<span>Label</span>
</label>
What is the cause for this behavior and how do I make it behave the same way?
I have tried using the inline-svg class and checked tag for tag what css properties are missing but I can't see something that differs which makes me believe it is some special behavior from the svg tag.
With the help from #enxaneta I learned that <symbol> is not visible unless used with <use> so I simply removed the <symbol> and replaced it with a <svg> and it works perfectly:
* {
box-sizing: border-box;
}
body {
font-family: "Open Sans", sans-serif;
font-size: 16px;
-webkit-font-smoothing: antialiased;
text-rendering: optimizelegibility;
color: #223254;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.cbx {
-webkit-user-select: none;
user-select: none;
cursor: pointer;
padding: 6px 8px;
border-radius: 6px;
overflow: hidden;
transition: all 0.2s ease;
}
.cbx:not(:last-child) {
margin-right: 6px;
}
.cbx:hover {
background: rgba(0, 119, 255, 0.06);
}
.cbx span {
float: left;
vertical-align: middle;
transform: translate3d(0, 0, 0);
}
.cbx span:first-child {
position: relative;
width: 18px;
height: 18px;
border-radius: 4px;
transform: scale(1);
border: 1px solid #cccfdb;
transition: all 0.2s ease;
box-shadow: 0 1px 1px rgba(0, 16, 75, 0.05);
}
.cbx span:first-child svg {
position: absolute;
top: 3px;
left: 2px;
fill: none;
stroke: #fff;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 16px;
stroke-dashoffset: 16px;
transition: all 0.3s ease;
transition-delay: 0.1s;
transform: translate3d(0, 0, 0);
}
.cbx span:last-child {
padding-left: 8px;
line-height: 18px;
}
.cbx:hover span:first-child {
border-color: #07f;
}
.inp-cbx {
position: absolute;
visibility: hidden;
}
.inp-cbx:checked+.cbx span:first-child {
background: #07f;
border-color: #07f;
animation: wave 0.4s ease;
}
.inp-cbx:checked+.cbx span:first-child svg {
stroke-dashoffset: 0;
}
.inline-svg {
position: absolute;
width: 0;
height: 0;
pointer-events: none;
user-select: none;
}
#-moz-keyframes wave {
50% {
transform: scale(0.9);
}
}
#-webkit-keyframes wave {
50% {
transform: scale(0.9);
}
}
#-o-keyframes wave {
50% {
transform: scale(0.9);
}
}
#keyframes wave {
50% {
transform: scale(0.9);
}
}
<input class="inp-cbx" id="morning" type="checkbox" />
<label class="cbx" for="morning">
<span>
<svg width="12px" height="10px" viewbox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg>
</span>
<span>Label</span>
</label>

How to hover the text with an animated icon

I really need some help. I'm having difficulties with hovering a Prev button. I want this button to roll over with the animated icon. However now, it only rollovers the animated icon, not the text. Here is a screenshot of the button, HTML and CSS code below. Thank you!
Button state now
https://vimeo.com/394493039
.link2 {
color: #000;
cursor: pointer;
font-weight: 400;
text-decoration: none;
}
.link--arrowed2 {
color: #000;
display: inline-block;
height: 2rem;
line-height: 2rem;
}
.link--arrowed2 .arrow-icon2 {
position: relative;
top: -1px;
-webkit-transition: -webkit-transform 0.3s ease;
transition: -webkit-transform 0.3s ease;
transition: transform 0.3s ease;
transition: transform 0.3s ease, -webkit-transform 0.3s ease;
vertical-align: middle;
}
.link--arrowed2 .arrow-icon--circle2 {
color: #000;
-webkit-transition: stroke-dashoffset 0.3s ease;
transition: stroke-dashoffset 0.3s ease;
stroke-dasharray: 95;
stroke-dashoffset: 95;
}
.link--arrowed2:hover .arrow-icon2 {
color: #000;
-webkit-transform: translate3d(-5px, 0, 0);
transform: translate3d(-5px, 0, 0);
}
.link--arrowed2:hover .arrow-icon--circle2 {
color: #000;
stroke-dashoffset: 0;
}
<div grid-row="" grid-pad="1.5" grid-gutter="3" class=""><div grid-col="x11" grid-pad="1.5"><small>
<a class="link link--arrowed2" href="#" rel="prev_page">
<svg class="arrow-icon2" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<g fill="none" stroke="#000000" stroke-width="1.5" stroke-linejoin="round" stroke-miterlimit="10">
<circle class="arrow-icon--circle2" cx="16" cy="16" r="15.12"></circle>
<path class="arrow-icon--arrow2" d="M18.00 23.00L10.0 16l7.00 -7.00M9.23 16h13.98"></path>
</g>
</svg></a><a class="link link--arrowed2" href="#" rel="prev_page"> Prev Project</a></small></div>
You're using too many a tags in your html. You only need one anchor tag for each link.
The result is that when you hover over any part of the link your effect will apply.
.link2 {
color: #000;
cursor: pointer;
font-weight: 400;
text-decoration: none;
}
.link--arrowed2 {
color: #000;
display: inline-block;
height: 2rem;
line-height: 2rem;
}
.link--arrowed2 .arrow-icon2 {
position: relative;
top: -1px;
-webkit-transition: -webkit-transform 0.3s ease;
transition: -webkit-transform 0.3s ease;
transition: transform 0.3s ease;
transition: transform 0.3s ease, -webkit-transform 0.3s ease;
vertical-align: middle;
}
.link--arrowed2 .arrow-icon--circle2 {
color: #000;
-webkit-transition: stroke-dashoffset 0.3s ease;
transition: stroke-dashoffset 0.3s ease;
stroke-dasharray: 95;
stroke-dashoffset: 95;
}
.link--arrowed2:hover .arrow-icon2 {
color: #000;
-webkit-transform: translate3d(-5px, 0, 0);
transform: translate3d(-5px, 0, 0);
}
.link--arrowed2:hover .arrow-icon--circle2 {
color: #000;
stroke-dashoffset: 0;
}
<div grid-row="" grid-pad="1.5" grid-gutter="3" class="">
<div grid-col="x11" grid-pad="1.5">
<small>
<a class="link link--arrowed2" href="#" rel="prev_page">
<svg class="arrow-icon2" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<g fill="none" stroke="#000000" stroke-width="1.5" stroke-linejoin="round" stroke-miterlimit="10">
<circle class="arrow-icon--circle2" cx="16" cy="16" r="15.12"></circle>
<path class="arrow-icon--arrow2" d="M18.00 23.00L10.0 16l7.00 -7.00M9.23 16h13.98"></path>
</g>
</svg>
<span>Prev Project</span>
</a>
</small>
</div>
</div>

Animation only happening on one checkbox despite different classes

I have found a checkbox which I really want to use but when I add more than 1 checkbox the animation only applies to the first one.
I have tried creating new class's like .cbx2 and .inp-cbx2 and applying the same style's but the animation still only applies to the first checkbox.
Could you please explain where I'm going wrong?
Thanks.
/* #### CHECKBOX STYLES AND ANIMATION #### */
.cbx {
margin: auto;
-webkit-user-select: none;
user-select: none;
cursor: pointer;
}
.cbx span {
display: inline-block;
vertical-align: middle;
transform: translate3d(0, 0, 0);
}
.cbx span:first-child {
position: relative;
width: 50px;
height: 50px;
border-radius: 0px;
transform: scale(1);
vertical-align: middle;
border: 1px solid #9098A9;
transition: all 0.2s ease;
}
.cbx span:first-child svg {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
fill: none;
stroke: #FFFFFF;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 16px;
stroke-dashoffset: 16px;
transition: all 0.3s ease;
transition-delay: 0.1s;
transform: translate3d(0, 0, 0);
}
.cbx span:first-child:before {
content: "";
width: 100%;
height: 100%;
background: #2bbfcb;
display: block;
transform: scale(0);
opacity: 1;
border-radius: 0%;
}
.cbx span:last-child {
padding-left: 8px;
}
.cbx:hover span:first-child {
border-color: #2bbfcb;
}
.inp-cbx:checked + .cbx span:first-child {
background: #2bbfcb;
border-color: #2bbfcb;
animation: wave 0.4s ease;
}
.inp-cbx:checked + .cbx span:first-child svg {
stroke-dashoffset: 0;
}
.inp-cbx:checked + .cbx span:first-child:before {
transform: scale(3.5);
opacity: 0;
transition: all 0.6s ease;
}
#keyframes wave {
50% {
transform: scale(0.9);
}
}
/* #### CHECKBOX STYLES AND ANIMATION #### */
.cbx2 {
margin: auto;
-webkit-user-select: none;
user-select: none;
cursor: pointer;
}
.cbx2 span {
display: inline-block;
vertical-align: middle;
transform: translate3d(0, 0, 0);
}
.cbx2 span:first-child {
position: relative;
width: 50px;
height: 50px;
border-radius: 0px;
transform: scale(1);
vertical-align: middle;
border: 1px solid #9098A9;
transition: all 0.2s ease;
}
.cbx2 span:first-child svg {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
fill: none;
stroke: #FFFFFF;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 16px;
stroke-dashoffset: 16px;
transition: all 0.3s ease;
transition-delay: 0.1s;
transform: translate3d(0, 0, 0);
}
.cbx2 span:first-child:before {
content: "";
width: 100%;
height: 100%;
background: #2bbfcb;
display: block;
transform: scale(0);
opacity: 1;
border-radius: 0%;
}
.cbx2 span:last-child {
padding-left: 8px;
}
.cbx2:hover span:first-child {
border-color: #2bbfcb;
}
.inp-cbx2:checked + .cbx2 span:first-child {
background: #2bbfcb;
border-color: #2bbfcb;
animation: wave 0.4s ease;
}
.inp-cbx2:checked + .cbx2 span:first-child svg {
stroke-dashoffset: 0;
}
.inp-cbx2:checked + .cbx2 span:first-child:before {
transform: scale(3.5);
opacity: 0;
transition: all 0.6s ease;
}
#keyframes wave {
50% {
transform: scale(0.9);
}
}
<input class="inp-cbx" id="cbx" type="checkbox" style="display: none;"/>
<label class="cbx" for="cbx"><span>
<svg width="40px" height="40px" viewbox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg></span><span>DIRECT</span></label>
<input class="inp-cbx2" id="cbx2" type="checkbox" style="display: none;"/>
<label class="cbx2" for="cbx"><span>
<svg width="40px" height="40px" viewbox="0 0 12 10" class="c">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg></span><span>MUTI ROUTE</span></label>
The whole reason classes exist in CSS is to make your styles reusable across multiple elements. There is no need to duplicate your CSS.
The reason the second check box doesn't work when using the same classes as the first is because you haven't updated the second labels for property. This property tells the browser the id of the form element that should be effected when the label is clicked.
In your case, the second label should look like this:
<label class="cbx" for="cbx2"><span>
/* #### CHECKBOX STYLES AND ANIMATION #### */
.cbx {
margin: auto;
-webkit-user-select: none;
user-select: none;
cursor: pointer;
}
.cbx span {
display: inline-block;
vertical-align: middle;
transform: translate3d(0, 0, 0);
}
.cbx span:first-child {
position: relative;
width: 50px;
height: 50px;
border-radius: 0px;
transform: scale(1);
vertical-align: middle;
border: 1px solid #9098A9;
transition: all 0.2s ease;
}
.cbx span:first-child svg {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
fill: none;
stroke: #FFFFFF;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 16px;
stroke-dashoffset: 16px;
transition: all 0.3s ease;
transition-delay: 0.1s;
transform: translate3d(0, 0, 0);
}
.cbx span:first-child:before {
content: "";
width: 100%;
height: 100%;
background: #2bbfcb;
display: block;
transform: scale(0);
opacity: 1;
border-radius: 0%;
}
.cbx span:last-child {
padding-left: 8px;
}
.cbx:hover span:first-child {
border-color: #2bbfcb;
}
.inp-cbx:checked+.cbx span:first-child {
background: #2bbfcb;
border-color: #2bbfcb;
animation: wave 0.4s ease;
}
.inp-cbx:checked+.cbx span:first-child svg {
stroke-dashoffset: 0;
}
.inp-cbx:checked+.cbx span:first-child:before {
transform: scale(3.5);
opacity: 0;
transition: all 0.6s ease;
}
#keyframes wave {
50% {
transform: scale(0.9);
}
}
<input class="inp-cbx" id="cbx" type="checkbox" style="display: none;" />
<label class="cbx" for="cbx"><span>
<svg width="40px" height="40px" viewbox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg></span><span>DIRECT</span></label>
<input class="inp-cbx" id="cbx2" type="checkbox" style="display: none;" />
<label class="cbx" for="cbx2"><span>
<svg width="40px" height="40px" viewbox="0 0 12 10" class="c">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg></span><span>MUTI ROUTE</span></label>

Hover function interfering with a href tag

I have this code right here, and what I am trying to accomplish is clickable icons but it seems like the hover function I have is not allowing me to click on the icons. I have already tried z-index but that doesn't seem to work.
body {
background-image: url("background.png");
background-size: 100%;
background-repeat: no-repeat;
background-color: rgb(19,68,97)
}
h1 {
font-family: 'Libre Baskerville', serif;
font-size: 50px;
padding: 0px 0px 0px 0px;
display: inline;
}
p {
font-family: 'Quicksand', sans-serif;
font-size: 15px;
padding: 0px 0px 0px 0px;
display: inline;
}
.boxAnimation {
width: 520px;
height: 300px;
position: relative;
background: rgba(255,255,255,0.3);
display: inline-block;
margin: 0 10px;
cursor: pointer;
color: #fff;
box-shadow: inset 0 0 0 3px rgba(192,192,192,1);
-webkit-transition: background 0.4s 0.5s;
transition: background 0.4s 0.5s;
z-index: 0;
margin: center;
}
svg {
position: absolute;
top: 0;
left: 0;
z-index: 0;
}
svg line {
stroke-width: 6;
stroke: #fff;
fill: none;
stroke-dasharray: 250;
-webkit-transition: -webkit-transform .6s ease-out;
transition: transform .6s ease-out;
z-index: 0;
}
div:hover {
background: rgba(255,255,255,0);
-webkit-transition-delay: 0s;
transition-delay: 0s;
}
div:hover svg line.top {
-webkit-transform: translateX(-400px);
transform: translateX(-400px);
}
div:hover svg line.bottom {
-webkit-transform: translateX(400px);
transform: translateX(400px);
}
div:hover svg line.left {
-webkit-transform: translateY(400px);
transform: translateY(400px);
}
div:hover svg line.right {
-webkit-transform: translateY(-400px);
transform: translateY(-400px);
}
.icons {
z-index: 5;
}
<link href="https://fonts.googleapis.com/css?family=Quicksand" rel="stylesheet">
<script src="https://use.fontawesome.com/e0037e252a.js"></script>
<body>
<center>
<div class="boxAnimation"> <svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
<line class="top" x1="0" y1="0" x2="1560" y2="0"/>
<line class="left" x1="0" y1="360" x2="0" y2="-720"/>
<line class="bottom" x1="520" y1="360" x2="-1040" y2="360"/>
<line class="right" x1="520" y1="0" x2="520" y2="1080"/>
</svg>
<h1>Donia Amer</h1>
<br>
<p>< insert title ></p>
<br>
<br>
<div class="icons"> <i class="fa fa-linkedin-square fa-inverse" aria-hidden="true" style="font-size:45px;"></i> <i class="fa fa-github-square" aria-hidden="true" style="font-size:45px;"></i> <i class="fa fa-twitter-square" aria-hidden="true" style="font-size:45px;"></i> <i class="fa fa-envelope-square" aria-hidden="true" style="font-size:45px;"></i> </div>
</div>
</center>
</body>
Add position:relative to .icons The z-index property specifies the stack order of an element. An element with greater stack order is always in front of an element with a lower stack order.
Note: z-index only works on positioned elements (position:absolute, position:relative, or position:fixed).
here is the example
body {
background-image: url("background.png");
background-size: 100%;
background-repeat: no-repeat;
background-color: rgb(19,68,97)
}
h1 {
font-family: 'Libre Baskerville', serif;
font-size: 50px;
padding: 0px 0px 0px 0px;
display: inline;
}
p {
font-family: 'Quicksand', sans-serif;
font-size: 15px;
padding: 0px 0px 0px 0px;
display: inline;
}
.boxAnimation {
width: 520px;
height: 300px;
position: relative;
background: rgba(255,255,255,0.3);
display: inline-block;
margin: 0 10px;
cursor: pointer;
color: #fff;
box-shadow: inset 0 0 0 3px rgba(192,192,192,1);
-webkit-transition: background 0.4s 0.5s;
transition: background 0.4s 0.5s;
z-index: 0;
margin: center;
}
svg {
position: absolute;
top: 0;
left: 0;
z-index: 0;
}
svg line {
stroke-width: 6;
stroke: #fff;
fill: none;
stroke-dasharray: 250;
-webkit-transition: -webkit-transform .6s ease-out;
transition: transform .6s ease-out;
z-index: 0;
}
div:hover {
background: rgba(255,255,255,0);
-webkit-transition-delay: 0s;
transition-delay: 0s;
}
div:hover svg line.top {
-webkit-transform: translateX(-400px);
transform: translateX(-400px);
}
div:hover svg line.bottom {
-webkit-transform: translateX(400px);
transform: translateX(400px);
}
div:hover svg line.left {
-webkit-transform: translateY(400px);
transform: translateY(400px);
}
div:hover svg line.right {
-webkit-transform: translateY(-400px);
transform: translateY(-400px);
}
.icons {
z-index: 5;
position:relative;
}
<link href="https://fonts.googleapis.com/css?family=Quicksand" rel="stylesheet">
<script src="https://use.fontawesome.com/e0037e252a.js"></script>
<body>
<center>
<div class="boxAnimation"> <svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
<line class="top" x1="0" y1="0" x2="1560" y2="0"/>
<line class="left" x1="0" y1="360" x2="0" y2="-720"/>
<line class="bottom" x1="520" y1="360" x2="-1040" y2="360"/>
<line class="right" x1="520" y1="0" x2="520" y2="1080"/>
</svg>
<h1>Donia Amer</h1>
<br>
<p>< Developer + Algorithm Enthusiast ></p>
<br>
<br>
<div class="icons"> <i class="fa fa-linkedin-square fa-inverse" aria-hidden="true" style="font-size:45px;"></i> <i class="fa fa-github-square" aria-hidden="true" style="font-size:45px;"></i> <i class="fa fa-twitter-square" aria-hidden="true" style="font-size:45px;"></i> <i class="fa fa-envelope-square" aria-hidden="true" style="font-size:45px;"></i> </div>
</div>
</center>
</body>
Just set the z-index property of svg to - value
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<title>Donia Amer</title>
<link href="https://fonts.googleapis.com/css?family=Quicksand" rel="stylesheet">
<script src="https://use.fontawesome.com/e0037e252a.js"></script>
<style>
body {
background-image:url("background.png");
background-size: 100%;
background-repeat: no-repeat;
background-color: rgb(19,68,97)
}
h1{
font-family: 'Libre Baskerville', serif;
font-size: 50px;
padding: 0px 0px 0px 0px;
display: inline;
}
p{
font-family: 'Quicksand', sans-serif;
font-size: 15px;
padding: 0px 0px 0px 0px;
display: inline;
}
.boxAnimation {
width: 520px;
height: 300px;
position: relative;
background:rgba(255,255,255,0.3);
display: inline-block;
margin: 0 10px;
cursor: pointer;
color: #fff;
box-shadow: inset 0 0 0 3px rgba(192,192,192,1);
-webkit-transition: background 0.4s 0.5s;
transition: background 0.4s 0.5s;
z-index: 0;
margin: center;
}
svg {
position: absolute;
top: 0;
left: 0;
z-index: -1;
}
svg line {
stroke-width: 6;
stroke: #fff;
fill: none;
stroke-dasharray: 250;
-webkit-transition: -webkit-transform .6s ease-out;
transition: transform .6s ease-out;
z-index: 0;
}
div:hover {
background: rgba(255,255,255,0);
-webkit-transition-delay: 0s;
transition-delay: 0s;
}
div:hover svg line.top {
-webkit-transform: translateX(-400px);
transform: translateX(-400px);
}
div:hover svg line.bottom {
-webkit-transform: translateX(400px);
transform: translateX(400px);
}
div:hover svg line.left {
-webkit-transform: translateY(400px);
transform: translateY(400px);
}
div:hover svg line.right {
-webkit-transform: translateY(-400px);
transform: translateY(-400px);
}
.icons{
z-index: 5;
}
</style>
</head>
<body>
<br><br><br><br><br><br><br><br><br><br><br><br>
<center>
<div class="boxAnimation">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
<line class="top" x1="0" y1="0" x2="1560" y2="0"/>
<line class="left" x1="0" y1="360" x2="0" y2="-720"/>
<line class="bottom" x1="520" y1="360" x2="-1040" y2="360"/>
<line class="right" x1="520" y1="0" x2="520" y2="1080"/>
</svg>
<h1>Donia Amer</h1><br>
<p>< Developer + Algorithm Enthusiast ></p>
<br>
<br>
<div class="icons">
<a href="https://stackoverflow.com/questions/ask">
<i class="fa fa-linkedin-square fa-inverse" aria-hidden="true" style="font-size:45px;"></i></a>
<i class="fa fa-github-square" aria-hidden="true" style="font-size:45px;"></i>
<i class="fa fa-twitter-square" aria-hidden="true" style="font-size:45px;"></i>
<i class="fa fa-envelope-square" aria-hidden="true" style="font-size:45px;"></i>
</div>
</div>
</center>
</body>
</html>
The trick is add new property in your icons selector position:relative
Reminder
z-index only works on positioned elements
CSS
.icons {
z-index: 5;
position:relative;
}
DEMO