Is it possible to prevent a CSS transition reversing off hover? - html

I have a hover animation that I have created with CSS. When the user hovers over the link the underline transitions from left to right changing the colour from black to grey. Currently as you would expect when the user moves their mouse off the link the transition reverses to start state.
I wondered if it is possible to prevent this reverse transition and instead fade the underline back to the colour black (the original start state)?
Here is a jsfiddle to work with.
Any suggestions/advise would be most welcome.
a.btn--tertiary {
padding-left: 0;
padding-right: 0;
background-color: transparent;
color: #000;
border: 0;
position: relative;
padding-bottom: 5px;
text-transform: uppercase;
text-decoration: none;
font-size: 40px;
}
.btn--tertiary:before {
content: '';
height: 2px;
right: 0;
width: 100%;
background: #000;
position: absolute;
bottom: 0;
opacity: 1;
transition: width 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0s;
z-index: 2;
border-left: 10px solid transparent;
}
.btn--tertiary:after {
content: '';
height: 2px;
left: 0;
right: auto;
width: 0%;
background: grey;
position: absolute;
bottom: 0;
transition: width 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0.1s;
z-index: 3;
}
.btn--tertiary:hover:before,
.btn--tertiary:focus:before {
width: 0%;
border-left: 20px solid $white;
}
.btn--tertiary:hover::after,
.btn--tertiary:focus::after {
right: 0;
width: 100%;
}

Yes, it is indeed. The trick is to make the width transition out take 0s with a delay of 1s.
html,
body {
margin: 0;
padding: 0;
}
a.btn--tertiary {
padding-left: 0;
padding-right: 0;
background-color: transparent;
color: #000;
border: 0;
position: relative;
padding-bottom: 5px;
text-transform: uppercase;
text-decoration: none;
font-size: 40px;
}
.btn--tertiary::before {
content: '';
height: 2px;
right: 0;
width: 100%;
background: #000;
position: absolute;
bottom: 0;
transition: width 0s;
z-index: 2;
border-left: 10px solid transparent;
}
.btn--tertiary::after {
content: '';
height: 2px;
left: 0;
right: auto;
width: 0%;
background: grey;
position: absolute;
bottom: 0;
opacity: 0;
transition: opacity .5s, width 0s .5s;
z-index: 3;
}
.btn--tertiary:hover:before,
.btn--tertiary:focus:before {
width: 0%;
border-left: 20px solid $white;
transition: width 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0s;
}
.btn--tertiary:hover::after,
.btn--tertiary:focus::after {
right: 0;
width: 100%;
opacity: 1;
transition: opacity 0s, width 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0.1s;
}
Button
Fiddle.

You can try like below. Check the comments for the details:
a.btn--tertiary {
color: #000;
position: relative;
padding-bottom: 5px;
display:inline-block;
text-decoration:none;
overflow:hidden;
font-size: 40px;
}
.btn--tertiary:before,
.btn--tertiary:after {
content: '';
height: 2px;
position: absolute;
bottom: 0;
}
.btn--tertiary:before {
right: 0;
width: 100%;
background: #000;
border-left: 20px solid #fff;
transition:
background 2s cubic-bezier(0.100, 0.600, 0.350, 1.000); /* transition the background on mouseout*/
}
.btn--tertiary:after {
left: 0;
width: 0%;
background: red;
}
.btn--tertiary:hover:before,
.btn--tertiary:focus:before {
width: 0%;
background: red;
transition:
width 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0s, /* visible transition of width on hover */
background 0s 1s; /* no transition but a background change after 1s */
}
.btn--tertiary:hover::after,
.btn--tertiary:focus::after {
right: 0;
width: 100%;
transition:
width 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0.1s; /* visible transition of width on hover */
}
Button

I hope this would help, please see the example below.
div {
text-align: center;
margin-top: 20px;
}
.btn--tertiary {
text-decoration: none;
font-family: sans-serif;
text-transform: uppercase;
display: inline-block;
position: relative;
overflow: hidden;
font-size: 45px;
color: black;
}
.btn--tertiary::before {
position: absolute;
content: '';
width: 100%;
height: 3px;
bottom: 0;
left: 0;
background: gray;
transform: scale(0, 1);
transform-origin: right;
transition: transform 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0s;
}
.btn--tertiary:hover::before {
transform: scale(1, 1);
transform-origin: left;
transition: transform 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) .1s;
}
.btn--tertiary::after {
position: absolute;
content: '';
width: 100%;
height: 3px;
bottom: 0;
right: 0;
background: black;
transform: scale(1, 1);
transform-origin: left;
transition: transform 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) .1s;
}
.btn--tertiary:hover::after {
transform: scale(0, 1);
transform-origin: right;
transition: transform 1s cubic-bezier(0.100, 0.600, 0.350, 1.000) 0s;
}
<div>
Button
</div>

Related

Draw ideal symmetric css border with border-radius

I'm trying to draw a border with border-radius: 8px;. It perfectly draws symmetrical border without border-radius but messed up with it. What am I doing wrong here?
setTimeout(function(){
document.getElementsByClassName('border')[0].classList.add('animate-border');
},100)
body {
background: white;
}
.main-container {
position:absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);
width: 300px;
height: 460px;
background: ;
}
.border:before {
border:2px solid black;
border-radius: 8px;
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 0;
height: 0;
border-top: 0;
border-left: 0;
pointer-events: none;
overflow: hidden;
opacity: 0;
transform: rotateZ(0) rotate(0);
}
.border.animate-border:before {
opacity: 1;
height: 100%;
width: 100%;
transition: opacity 0s ease,width 0.5s ease, height 0.5s 0.5s ease;
overflow: hidden;
transform: rotateZ(0) rotate(0);
}
.border:after {
border: 2px solid black;
border-radius: 8px;
content: '';
position: absolute;
top: 0;
right: 0;
width: 0;
height: 0;
border-bottom: 0;
border-right: 0;
opacity: 0;
overflow: hidden;
transform: rotateZ(0) rotate(0);
}
.border.animate-border:after {
opacity: 1;
height: 100%;
width: 100%;
overflow: hidden;
transition: opacity 0s 1s ease,width 0.5s 1s ease, height 0.5s 1.5s ease;
transform: rotateZ(0) rotate(0);
}
<div class='main-container border'></div>
CSS:
body {
background: white;
}
.main-container {
position:absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);
width: 300px;
height: 460px;
background: ;
}
.border:before {
border:2px solid black;
border-radius: 8px;
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 0;
height: 0;
border-top: 0;
border-left: 0;
pointer-events: none;
overflow: hidden;
opacity: 0;
transform: rotateZ(0) rotate(0);
}
.border.animate-border:before {
opacity: 1;
height: 100%;
width: 100%;
transition: opacity 0s ease,width 0.5s ease, height 0.5s 0.5s ease;
overflow: hidden;
transform: rotateZ(0) rotate(0);
}
.border:after {
border: 2px solid black;
border-radius: 8px;
content: '';
position: absolute;
top: 0;
right: 0;
width: 0;
height: 0;
border-bottom: 0;
border-right: 0;
opacity: 0;
overflow: hidden;
transform: rotateZ(0) rotate(0);
}
.border.animate-border:after {
opacity: 1;
height: 100%;
width: 100%;
overflow: hidden;
transition: opacity 0s 1s ease,width 0.5s 1s ease, height 0.5s 1.5s ease;
transform: rotateZ(0) rotate(0);
}
First of all, you may apply box-sizing: border-box in all elements (and pseudo-elements) to make the alignment easier. It makes the browser count the border on width and height calculation. That solves your misalignment problem.
Second, since you're resizing the element, the rounded corners get stretched in the middle of the animation. I see no easy way prevent that from happening. But you can disguise it by also animating the right property of the :after pseudo-element, like I did below. That and a faster timing may get you there with your animation.
BTW, it would be more performant if you animated transform: scaleX(...) scaleY(...) instead of width and height, because they're GPU accelerated.
setTimeout(function(){
document.getElementsByClassName('border')[0].classList.add('animate-border');
},100)
body {
background: white;
}
*, *:before, *:after { /* Applies to ALL elements and pseudo-elements */
box-sizing: border-box;
}
.main-container {
position:absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);
width: 300px;
height: 160px;
background: ;
}
.border:before {
border:2px solid black;
border-radius: 8px;
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 0;
height: 0;
border-top: 0;
border-left: 0;
pointer-events: none;
overflow: hidden;
opacity: 0;
transform: rotateZ(0) rotate(0);
}
.border.animate-border:before {
opacity: 1;
height: 100%;
width: 100%;
transition: opacity 0s ease,width 0.5s ease, height 0.5s 0.5s ease;
overflow: hidden;
transform: rotateZ(0) rotate(0);
}
.border:after {
border: 2px solid black;
border-radius: 8px;
content: '';
position: absolute;
top: 0;
right: 6px; /* a little offset to hide the squared edge */
width: 0;
height: 0;
border-bottom: 0;
border-right: 0;
opacity: 0;
overflow: hidden;
transform: rotateZ(0) rotate(0);
}
.border.animate-border:after {
opacity: 1;
height: 100%;
width: 100%;
right: 0; /* the wanted right position */
overflow: hidden;
transition: opacity 0s 1s ease,width 0.5s 1s ease, height 0.5s 1.5s ease,right 1s 1s ease; /* Animated 'right' so it slowly gets back to its position */
transform: rotateZ(0) rotate(0);
}
<div class='main-container border'></div>
PS.: I changed the box height to make it fit inside the snippet here.
You just need to specify properties below to pseudo elements because they are position absolute
Add top:0 to .border:before css and add left:0 to .border:after css

Set own styles to content in before element

I've just created a button. I've found a problem where my content doesn't fit on it's place.
Here is my code:
.btn-red {
display: inline-block;
padding: 13px 20px;
color: #fff;
text-decoration: none;
position: relative;
background: #f42f2c;
font: 10px "Oswald", sans-serif;
letter-spacing: 0.4em;
text-align: center;
text-indent: 2px;
text-transform: uppercase;
transition: color 0.1s linear 0.05s;
border-radius: 0;
border: 1px solid #f42f2c;
}
.btn-red:focus {
box-shadow:none !important;
}
.btn-red::before {
content: "READ MORE";
display: block;
position: absolute;
top: 50%;
left: 0;
width: 100%;
height: 1px;
background: #f9f9ff;
color:#f42f2c !important;
z-index: 1;
opacity: 0;
transition: height 0.2s ease, top 0.2s ease, opacity 0s linear 0.2s;
}
.btn-red::after {
transition: border 0.1s linear 0.05s;
}
.btn-red .btn-red-inner {
position: relative;
z-index: 2;
}
.btn-red:hover {
transition: color 0.1s linear 0s;
text-decoration: none;
color: #f42f2c !important;
}
.btn-red:hover::before {
top: 0;
height: 100%;
opacity: 1;
transition: height 0.2s ease, top 0.2s ease, opacity 0s linear 0s;
}
.btn-red:hover::after {
transition: border 0.1s linear 0s;
}
<a href="o-nas.php" class="btn-red">
<span class="btn-inner">READ MORE</span>
</a>
I tried to add padding: 13px 20px to .btn-red::before, but it has some bugs and I don't know how to solve this.
I think I achieve the same thing that you wanted without using :before to control the button text. Look below:
.btn-red {
position: relative;
display: inline-flex;
box-sizing: border-box;
padding: 13px 20px;
text-decoration: none;
background-color: #f42f2c;
border: 1px solid #f42f2c;
}
.btn-red:before {
position: absolute;
top: 50%;
left: 0;
width: 100%;
height: 0;
content: "";
background-color: #fff;
transform: translateY(-50%);
transition: height 0.2s ease-in-out;
}
.btn-red .btn-inner {
font: 10px "Oswald", sans-serif;
color: #fff;
line-height: 1em;
letter-spacing: 0.4em;
text-transform: uppercase;
z-index: 1;
transition: color 0.2s ease-in-out;
}
.btn-red:hover:before {
height: 100%;
}
.btn-red:hover .btn-inner {
color: #f42f2c;
}
<a class="btn-red" href="#" title="Read More">
<span class="btn-inner">Read more</span>
</a>
Hope this can help you anyway. If you have any doubt about the code, please, just let me know :)
Cheers!

Animate borders (border-left, border-top) of box on hover

I would like to animate two borders on hover specifically border-left and border-top. After doing some research it does not seem you can actually "animate" the borders themselves so you have to create a "line" which on hover should have its width set to 100% to have the same effect.
I know how to do this with underlining menu items, but I would like to do it with this box I'm trying to create.
Specifically on hover (while maintaining the css effects already written up)
1) border-left should extend to the top and right after that-> 2) border-top extending from the left to the right.
Also was wondering how I can choose which borders to extend if I don't want to to just do border-left or border-top.
This is my box thus far (unfortunately nothing with animating borders):
CSS:
#txt{
position:absolute;
top:50%;
left:50%;
transform:translate(-50%, -50%);
font-size:2vw;
}
#box{
position:fixed;
top:25%;
left:25%;
height:20vw;
width:20vw;
border-right: 2px solid deepskyblue;
border-bottom: 2px solid deepskyblue;
background-color:black;
color:ghostwhite;
}
#box:hover{
color:deepskyblue;
transition: color 0.25s ease;
}
#box:after{
content:"";
position:absolute;
bottom: 0;
left: 0;
width:100%;
height:100%;
transform: scale(0, 0);
transform-origin:bottom right;
background: ghostwhite;
z-index: -1;
transition: transform 0.25s ease;
}
#box:hover::after{
transform: scale(1, 1);
color:deepskyblue;
}
HTML:
<div id="box">
<span id="txt">TEXT</span>
</div>
You can make the #txt element as large as the parent box and then use pseudo-element on that to make "borders" and animate the dimensions of those pseudo-elements.
If you add a transiton-delay in I think you can get the effect you are after.
#txt {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
display: flex;
justify-content: center;
align-items: center;
}
#box {
font-size: 2vw;
position: fixed;
top: 1em;
left: 40vw;
height: 20vw;
width: 20vw;
background-color: black;
color: ghostwhite;
}
#box:hover {
color: deepskyblue;
transition: color 0.25s ease;
}
#box:after {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
transform: scale(0, 0);
transform-origin: bottom right;
background: ghostwhite;
z-index: -1;
transition: transform 0.25s ease;
}
#box:hover::after {
transform: scale(1, 1);
color: deepskyblue;
}
#txt::before {
content: "";
position: absolute;
z-index: 2;
left: 0;
bottom: 0;
height: 0;
}
#txt::before {
width: 0;
border-left: 2px solid deepskyblue;
transition: height .25s .5s ease;
}
#txt:hover::before {
height: 100%;
}
#txt::after {
content: "";
position: absolute;
width: 0%;
top: 0;
left: 0;
border-top: 2px solid deepskyblue;
transition: width 0.25s .75s ease;
}
#txt:hover::after {
width: 100%;
}
<div id="box">
<span id="txt">TEXT</span>
</div>

How to do an animation backwards when its not hovering anymore?

I found this animated button at codepen, I changed a little bit and now want to add it to my code.
But I want the animation go backwards when the element is not hovered anymore. At the moment it goes again from top to bottom. But I wanted this:
Hover: Top to Bottom
End of Hover: Bottom to Top
I thought this is possible with :after:hover. But it doesn't worked and I'm not pretty sure if this is the correct way.
.btn {
border: 0;
padding: 0 24px;
display: block;
position: relative;
transition: border-bottom-color 0.2s cubic-bezier(0.215, 0.61, 0.355, 1) 0.25s;
text-align: center;
border-bottom: solid 3px;
height: 48px;
}
.btn:not(.btn-disabled):before {
content: '';
position: absolute;
left: 0px;
bottom: 0px;
height: 0px;
width: 100%;
z-index: 0;
transition: all 0.3s cubic-bezier(1, 1, 1, 1) 0s;
}
.btn:not(.btn-disabled):hover:before {
top: 0%;
bottom: auto;
height: 100%;
}
.btn span {
position: relative;
z-index: 2;
}
.btn:focus {
outline: 0;
}
.btn:not(.btn-disabled):hover {
color: #ff0080;
border-bottom-color: #ffffcc;
}
.btn:not(.btn-disabled):active {
border-bottom-color: #0040ff;
transition-delay: 0s;
transition-duration: 0.15s;
}
.btn-primary {
background-color: #ffffcc;
color: #ff0080;
}
.btn-primary:before {
background: #fff;
}
<button type="button" class="btn btn-primary">
<span>Small Button</span>
</button>
Actually my Code is in Sass but I changed it here for the demonstration.
To prevent the transition from starting from the top when unhovered, set top: 0 and height: 0 on the pseudo element when not hovered, and change the height to 100% when hovered. When the height moves from 0 to 100% the direction of the animation would be down, and when it goes from 100% to 0, the direction would be up.
.btn {
border: 0;
padding: 0 24px;
display: block;
position: relative;
transition: border-bottom-color 0.2s cubic-bezier(0.215, 0.61, 0.355, 1) 0.25s;
text-align: center;
border-bottom: solid 3px;
height: 48px;
}
.btn:not(.btn-disabled):before {
content: '';
position: absolute;
top: 0;
left: 0;
height: 0;
width: 100%;
z-index: 0;
transition: all 0.3s cubic-bezier(1, 1, 1, 1) 0s;
}
.btn:not(.btn-disabled):hover:before {
height: 100%;
}
.btn span {
position: relative;
z-index: 2;
}
.btn:focus {
outline: 0;
}
.btn:not(.btn-disabled):hover {
color: #ff0080;
border-bottom-color: #ffffcc;
}
.btn:not(.btn-disabled):active {
border-bottom-color: #0040ff;
transition-delay: 0s;
transition-duration: 0.15s;
}
.btn-primary {
background-color: #ffffcc;
color: #ff0080;
}
.btn-primary:before {
background: #fff;
}
<button type="button" class="btn btn-primary"><span>Small Button</span></button>
Change the btn:before and provide
top: 0;
left: 0;
height: 0;

Draw outline around button on hover

I would like to "draw" an outline around rectangle buttons, meaning I'd like for the border to transition but not fade in. I already have a bunch of effects on these buttons.. I tried to apply an already-made exemple of draw outline CSS but it didn't do anything..
Here's my code
function hoverIcons(classnm) {
document.getElementById(classnm).css({height: '+=30%', width: '+=30%'});
}
function nothoverIcons(classnm) {
document.getElementById(classnm).css({height: '+=30%', width: '+=30%'});
}
#menu {
position: fixed;
bottom: 20;
right: 20;
width: 80;
height: 30px;
background-color: Menu background;
z-index: 10;
}
#mainicons {
position: fixed;
bottom: 20px;
right: 193px;
text-align: center;
}
#mainicons i {
display: inline-block;
margin-top: 0;
margin-left: -3px;
height: 30px;
width: 50px;
padding: 10px;
color-color: Main icon;
background-color: Main icon background;
text-transform: uppercase;
font-size: 15px;
line-height: 30px;
-webkit-transition: all .7s ease;
-moz-transition: all .7s ease;
-o-transition: all .7s ease;
transition: all .7s ease;
}
#mainicons i:hover {
color-color: Hover;
background-color: Main icon;
transform: scale(1.1);
-webkit-transition: all .7s ease;
-moz-transition: all .7s ease;
-o-transition: all .7s ease;
transition: all .7s ease;
}
/*-- BEGINNING BORDER EFFECT (PASTED) --*/
#mainicons {
transition: color 0.25s;
box-sizing: border-box;
}
#mainicons::before, #mainicons::after {
box-sizing: inherit;
content: '';
position: absolute;
width: 100%;
height: 100%;
}
#mainicons::before, #mainicons::after {
border: 2px solid transparent;
width: 0;
height: 0;
}
#mainicons::before {
top: 0;
left: 0;
}
#mainicons::after {
bottom: 0;
right: 0;
}
#mainicons:hover {
color: #97c5e0;
}
#mainicons:hover::before, #mainicons:hover::after {
width: 100%;
height: 100%;
}
#mainicons:hover::before {
border-top-color: #97c5e0;
border-right-color: #97c5e0;
transition: width 0.25s ease-out, height 0.25s ease-out 0.25s;
}
#mainicons:hover::after {
border-bottom-color: #97c5e0;
border-left-color: #97c5e0;
transition: border-color 0s ease-out 0.5s, width 0.25s ease-out 0.5s, height 0.25s ease-out 0.75s;
}
/*-- BEGINNING BORDER EFFECT (PASTED) --*/
/* originally written in SCSS
#mainicons {
transition: color 0.25s;
box-sizing: border-box;
&::before,
&::after {
box-sizing: inherit;
content: '';
position: absolute;
width: 100%;
height: 100%;}
&::before,
&::after {
border: 2px solid transparent;
width: 0;
height: 0;
}
&::before {
top: 0;
left: 0;
}
&::after {
bottom: 0;
right: 0;
}
&:hover {
color: #97c5e0;
}
&:hover::before,
&:hover::after {
width: 100%;
height: 100%;
}
&:hover::before {
border-top-color: #97c5e0;
border-right-color: #97c5e0;
transition:
width 0.25s ease-out,
height 0.25s ease-out 0.25s;
}
&:hover::after {
border-bottom-color: #97c5e0;
border-left-color: #97c5e0;
transition:
border-color 0s ease-out 0.5s,
width 0.25s ease-out 0.5s,
height 0.25s ease-out 0.75s;
}
}
*/
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
<div id="menu">
<div id="mainicons" onmouseover="hoverIcons('mainicons')" onmouseout="nothoverIcons('mainicons')">
<i class="fa fa-home"></i>
<i class="fa fa-envelope"></i>
<i class="fa fa-pencil "></i>
<i class="fa fa-clock-o"></i>
</div>
</div>
I have to admit it's very complicated for me to understand what he/she tried to do for the outline thing (https://codepen.io/giana/pen/yYBpVY).. So if you have a better/easier way to do this, thanks a lot!!
your html seems funny - you have html for a center button and yet none appears??
you can use just 'purple' or 'blue' etc.. for colors if you don't want to use html codes/id you find it easier, you don't need to define these in your css - that dollar sign is usually used in jquery - i haven't seen it used in css before but that's just me, i won't say it can't be used [or i'd stand to be corrected]. EDIT: CSS vars are still experimental technology with no support in Chrome or IE (although supported in edge).. as there's no support in Chrome, I'd hold off using it for now
I adjusted your code somewhat. I added a display:block to the button code so now they display one under the other in the window. Remove this and they will display as the layout will display in your original code. For purposes of snippet/jsfiddle window it's just handier. I replaced the colours with the html colors that you had in your definitions but like i say, in future you can just say border-color:red etc.
Note that this is only meant as a guide. Adjust as you see fit!
button {
display: block;
background: none;
border: 0;
box-sizing: border-box;
margin: 1em;
padding: 1em 2em;
box-shadow: inset 0 0 0 2px #f45e61;
color: #f45e61;
font-size: inherit;
font-weight: 700;
position: relative;
vertical-align: middle;
&::before,
&::after {
box-sizing: inherit;
content: '';
position: relative;
width: 100%;
height: 100%;
}
}
.draw {
transition: color 0.25s;
border: 2px solid transparent;
height: 100%;
}
.draw::after {
bottom: 0;
right: 0;
}
.draw:hover {
color: #60daaa;
border-color: #fbca67;
width: 100%;
}
.meet {
border-top-color: #fbca67;
border-right-color: #fbca67;
}
.meet::after {
top: 0;
left: 0;
}
.meet:hover {
color: #fbca67;
z-index: 1;
border-bottom-color: #fbca67!important;
border-left-color: #fbca67!important;
}
.center {
width: 200px;
height: 100px;
text-align: center;
padding: 10px;
border-style: solid;
border-top-width: 2px!important;
border-bottom-width: 2px!important;
border-color: #6477b9;
color: #6477b9;
}
.center:hover {
color: #FF0000;
border-left-width: 2px!important;
border-right-width: 2px!important;
z-index: 90!important;
}
.center:focus {
border: 3px dashed red;
color: forestgreen;
}
.spin {
width: 5em;
height: 5em;
padding: 0;
border-width: 2px;
border-style: solid;
border-color: transparent;
top: 0;
left: 0;
}
.circle {
border-radius: 100%;
box-shadow: none;
}
.thick {
color: #f45e61;
z-index: -1;
background: #ffffff;
border-color: #f45e61;
}
.thick:hover {
color: #fff;
font-weight: 700;
background: #f45e61;
}
.thick::after {
mix-blend-mode: color-dodge;
}
/* Page styling */
html {
background: #4b507a;
}
body {
background: #fefefe;
color: #4b507a;
font: 300 24px/1.5 Lato, sans-serif;
margin: 1em auto;
max-width: 36em;
padding: 1em 1em 2em;
text-align: center;
}
.buttons {
isolation: isolate;
}
h1 {
font-weight: 300;
font-size: 2.5em;
}
<!---<h1>CSS Border Transitions</1>-->
<section class="buttons">
<button class="draw">Draw</button>
<button class="draw meet">Draw Meet</button>
<button class="center">Center</button>
<button class="spin">Spin</button>
<button class="spin circle">Spin Circle</button>
<button class="spin thick">Spin Thick</button>
</section>
Fiddle here
oups, i finally understood, effect is actually set on the container and you wish to set it on the links.
You basicly need to update the selector .
example
function hoverIcons(classnm) {
// document.getElementById(classnm).css({height: '+=30%', width: '+=30%'});
}
function nothoverIcons(classnm) {
// document.getElementById(classnm).css({height: '+=30%', width: '+=30%'});
}
#menu {
position: fixed;
bottom: 20;
right: 20;
width: 80;
height: 30px;
background-color: Menu background;
z-index: 10;
}
#mainicons {
position: fixed;
bottom: 20px;
right: 193px;
text-align: center;
}
#mainicons a {
transition: color 0.25s;
display: inline-block;
position: relative;
margin: 0 25px;
padding: 10px 20px;
box-sizing: border-box;
}
a::before,
a::after {
content: '';
position: absolute;
box-sizing: border-box;
width: 100%;
height: 100%;
}
a::before,
a::after {
border: 2px solid transparent;
width: 0;
height: 0;
}
a::before {
top: 0;
left: 0;
}
a::after {
bottom: 0;
right: 0;
}
a:hover {
color: #97c5e0;
}
a:hover::before,
a:hover::after {
width: 100%;
height: 100%;
}
a:hover::before {
border-top-color: #97c5e0;
border-right-color: #97c5e0;
transition: width 0.25s ease-out, height 0.25s ease-out 0.25s;
}
a:hover::after {
border-bottom-color: #97c5e0;
border-left-color: #97c5e0;
transition: border-color 0s ease-out 0.5s, width 0.25s ease-out 0.5s, height 0.25s ease-out 0.75s;
}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" />
<div id="menu">
<div id="mainicons" onmouseover="hoverIcons('mainicons')" onmouseout="nothoverIcons('mainicons')">
<i class="fa fa-home"></i>
<i class="fa fa-envelope"></i>
<i class="fa fa-pencil "></i>
<i class="fa fa-clock-o"></i>
</div>
</div>
#mainicons a{ /* select here the links */
transition: color 0.25s;
box-sizing: border-box;
display:inline-block;
position:relative ;
margin:0 25px;
padding: 10px 20px;
box-sizing:content-box;
&::before,
&::after {
content: '';
position: absolute;
box-sizing: border-box;
width: 100%;
height: 100%;
}
&::before,
&::after {
border: 2px solid transparent;
width: 0;
height: 0;
}
&::before {
top: 0;
left: 0;
}
&::after {
bottom: 0;
right: 0;
}
&:hover {
color: #97c5e0;
}
&:hover::before,
&:hover::after {
width: 100%;
height: 100%;
}
&:hover::before {
border-top-color: #97c5e0;
border-right-color: #97c5e0;
transition:
width 0.25s ease-out,
height 0.25s ease-out 0.25s;
}
&:hover::after {
border-bottom-color: #97c5e0;
border-left-color: #97c5e0;
transition:
border-color 0s ease-out 0.5s,
width 0.25s ease-out 0.5s,
height 0.25s ease-out 0.75s;
}
}