Font color animated purely with CSS transitions - html

I was playing around with some CSS transitions, and trying to figure this out. I would like the text color to change (from left to right) INSTEAD of the background.
Here is the code: (codepen here: http://codepen.io/xkurohatox/pen/zGboMz)
HTML:
View Cart
CSS:
a.added_to_cart.wc-forward {
font-size:100px;
color:black;
}
a.added_to_cart.wc-forward {
display: inline-block;
vertical-align: middle;
-webkit-transform: translateZ(0);
transform: translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-osx-font-smoothing: grayscale;
position: relative;
-webkit-transition-property: color;
transition-property: color;
-webkit-transition-duration: 0.5s;
transition-duration: 0.5s;
}
a.added_to_cart.wc-forward:before {
content: "";
position: absolute;
z-index: -1;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: red;
-webkit-transform: scaleX(0);
transform: scaleX(0);
-webkit-transform-origin: 0 50%;
transform-origin: 0 50%;
-webkit-transition-property: transform;
transition-property: transform;
-webkit-transition-duration: 0.5s;
transition-duration: 0.5s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
a.added_to_cart.wc-forward:hover, a.added_to_cart.wc-forward:focus, a.added_to_cart.wc-forward:active {
color: white;
}
a.added_to_cart.wc-forward:hover:before, a.added_to_cart.wc-forward:focus:before, a.added_to_cart.wc-forward:active:before {
-webkit-transform: scaleX(1);
transform: scaleX(1);
-webkit-transition-timing-function: cubic-bezier(0.52, 1.64, 0.37, 0.66);
transition-timing-function: cubic-bezier(0.52, 1.64, 0.37, 0.66);
}
I already tried the obvious, such as changing background-color to color and playing around with translateZ. I don't think I've ever seen a css font color transition before so I would LOVE to see if anyone here is talented enough to come up with one.
Got the base code from here: https://github.com/IanLunn/Hover
Thank you in advance xx :)

It absolutely can be done using a little bit of trickery. Here's a working example that uses a mask to reveal the colored text.
Codepen: http://codepen.io/maxlaumeister/pen/eNXBaW
Live Demo:
a.added_to_cart.wc-forward {
font-size:100px;
color:black;
}
a.added_to_cart.wc-forward {
display: inline-block;
vertical-align: middle;
-webkit-transform: translateZ(0);
transform: translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-osx-font-smoothing: grayscale;
position: relative;
-webkit-transition-property: color;
transition-property: color;
-webkit-transition-duration: 0.5s;
transition-duration: 0.5s;
}
.mask {
display: inline-block;
position: absolute;
top: 0;
left: 0;
width: 0px;
overflow: hidden;
-webkit-transform-origin: 0 50%;
transform-origin: 0 50%;
-webkit-transition-property: width;
transition-property: width;
-webkit-transition-duration: 0.5s;
transition-duration: 0.5s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
text-shadow:
-1px -1px 0 red,
1px -1px 0 red,
-1px 1px 0 red,
1px 1px 0 red;
}
.mask a.added_to_cart.wc-forward {
color: red;
}
#container:hover .mask {
width: 500px;
-webkit-transition-timing-function: cubic-bezier(0.52, 1.64, 0.37, 0.66);
transition-timing-function: cubic-bezier(0.52, 1.64, 0.37, 0.66);
}
body {
margin: 0;
}
a.added_to_cart.wc-forward.under {
position: absolute;
left: 0;
top: 0;
}
#inner {
width: 500px;
}
<div id="container">
View Cart
<div class="mask">
<div id="inner">
View Cart
</div>
</div>
</div>

I removed background color from a.added_to_cart.wc-forward:before
CSS
a.added_to_cart.wc-forward {
font-size:100px;
color:black;
}
a.added_to_cart.wc-forward {
display: inline-block;
vertical-align: middle;
-webkit-transform: translateZ(0);
transform: translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-osx-font-smoothing: grayscale;
position: relative;
-webkit-transition-property: color;
transition-property: color;
-webkit-transition-duration: 0.5s;
transition-duration: 0.5s;
}
a.added_to_cart.wc-forward:before {
content: "";
position: absolute;
z-index: -1;
top: 0;
left: 0;
right: 0;
bottom: 0;
-webkit-transform: scaleX(0);
transform: scaleX(0);
-webkit-transform-origin: 0 50%;
transform-origin: 0 50%;
-webkit-transition-property: transform;
transition-property: transform;
-webkit-transition-duration: 0.5s;
transition-duration: 0.5s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
a.added_to_cart.wc-forward:hover, a.added_to_cart.wc-forward:focus, a.added_to_cart.wc-forward:active {
color: red;
}
a.added_to_cart.wc-forward:hover:before, a.added_to_cart.wc-forward:focus:before, a.added_to_cart.wc-forward:active:before {
-webkit-transform: scaleX(1);
transform: scaleX(1);
-webkit-transition-timing-function: cubic-bezier(0.52, 1.64, 0.37, 0.66);
transition-timing-function: cubic-bezier(0.52, 1.64, 0.37, 0.66);
}
HTML
View Cart
Demo here

Related

Positioned element is off when on Safari`

I have a button with arrows that is supposed to appear and move down when moused over. On Chrome and Firefox it works fine but when I open it up on Safari the arrows are too low- they aren't positioned correctly. I have heard about people specifying "top" and :left" but that doesn't seem to work for me. I don't know why this is but it seems to be due to the position: relative.
Code:
<a class="details" href="#scroll"> <span class="details__border--bottom">More Details</span>
</a>
<div class="top-portion__arrows">
<span class="top-portion__arrows--hide"></span>
<span class="top-portion__arrows--hide"></span>
<span class="top-portion__arrows--hide"></span>
</div>
a.details {
border: 2.5px solid white;
padding: 8px 62px;
padding-top: 11px;
font-family: 'Roboto', sans-serif;
font-size: 1.75rem;
background-color: rgba(214, 128, 0, 0.45);
color: white;
cursor: pointer;
position: relative;
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%);
left: 50%;
top: 5%;
z-index: 1;
display: inline-block;
}
a.details:hover,
a.details:focus {
background-color: rgba(231, 147, 21, 0.25);
-webkit-transition: .5s ease-in;
-o-transition: .5s ease-in;
transition: .5s ease-in;
}
a.details:hover,
a.details:focus {
border: 3.5px solid white;
-webkit-transition: .15s;
-o-transition: .15s;
transition: .15s;
}
a.details:active {
background-color: rgba(247, 195, 100, 0.75);
-webkit-transition: .15s;
-o-transition: .15s;
transition: .15s;
}
.details__border--bottom {
display: inline-block;
padding: 2px 0px 4px;
margin: 0px 8px 0px;
position: relative;
}
.details__border--bottom:before {
content: '';
position: absolute;
width: 100%;
height: 0px;
border-bottom: 2.5px solid white;
bottom: 2px;
-webkit-transform: scaleX(0);
-ms-transform: scaleX(0);
transform: scaleX(0);
-webkit-transition: -webkit-transform 0.25s ease-in-out;
-webkit-transition: -webkit-transform 0.45s ease-in-out;
transition: -webkit-transform 0.45s ease-in-out;
-o-transition: transform 0.45s ease-in-out;
transition: transform 0.45s ease-in-out;
transition: transform 0.45s ease-in-out, -webkit-transform 0.45s ease-in-out;
}
a:hover .details__border--bottom:before,
a:focus .details__border--bottom:before {
-webkit-transform: scaleX(1);
-ms-transform: scaleX(1);
transform: scaleX(1);
}
.top-portion__arrows {
position: relative;
width: 0%;
top: 10%;
left: 51.5%;
}
.top-portion__arrows .top-portion__arrows--hide {
opacity: 0;
display: block;
width: 120px;
height: 120px;
border-bottom: 3px solid white;
border-right: 3px solid white;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
margin: -85px;
}
a.details:hover + .top-portion__arrows .top-portion__arrows--hide,
a.details:focus + .top-portion__arrows .top-portion__arrows--hide {
opacity: 1;
-webkit-animation: animate .65s ease;
animation: animate .65s ease;
}
.top-portion__arrows .top-portion__arrows--hide:hover .details__border--full,
.top-portion__arrows .top-portion__arrows--hide:focus .details__border--full {
border: 2.5px solid white;
-webkit-transition: .2s ease-in;
-o-transition: .2s ease-in;
transition: .2s ease-in;
}
#-webkit-keyframes animate {
0%{
opacity: 0;
-webkit-transform: rotate(45deg) translate(-10px,-10px);
transform: rotate(45deg) translate(-10px,-10px);
}
50%{
opacity: .5;
}
100%{
opacity: 1;
-webkit-transform: rotate(45deg) translate(0px,0px);
transform: rotate(45deg) translate(0px,0px);
}
}
#keyframes animate {
0%{
opacity: 0;
-webkit-transform: rotate(45deg) translate(-10px,-10px);
transform: rotate(45deg) translate(-10px,-10px);
}
50%{
opacity: .5;
}
100%{
opacity: 1;
-webkit-transform: rotate(45deg) translate(0px,0px);
transform: rotate(45deg) translate(0px,0px);
}
}
You can detect whether a user is browsing on safari with some javascript and then if they are browsing on safari, style the buttons a certain way by changing the margin-left and margin-top. Here is the code to detect whether the user is on safari:
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('safari') != -1) {
if (ua.indexOf('chrome') > -1) {
alert("chrome") // Chrome
} else {
alert("safari") // Safari
}
}
Edit: Your full code:
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('safari') != -1) {
if (ua.indexOf('chrome') > -1) {
} else {
document.getElementById("btn1").style.marginTop = "80%"; }
}

Hide the overflow on a circular button

I tried some hover effects from here and I tried to put the radial out effect on to a circle (border-radius: 50%) but there is a rectangle showing up for a brief moment when you actually hover over the circle.
my code:
button {
background: #F0F1F2;
border: none;
cursor: pointer;
border-radius: 50%;
width: 100px;
height: 100px;
}
.hvr-radial-out {
display: inline-block;
vertical-align: middle;
-webkit-transform: perspective(1px) translateZ(0);
transform: perspective(1px) translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
position: relative;
overflow: hidden;
background: #e1e1e1;
-webkit-transition-property: color;
transition-property: color;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
}
.hvr-radial-out:before {
content: "";
position: absolute;
z-index: -1;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #2098D1;
border-radius: 100%;
-webkit-transform: scale(0);
transform: scale(0);
-webkit-transition-property: transform;
transition-property: transform;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
.hvr-radial-out:hover, .hvr-radial-out:focus, .hvr-radial-out:active {
color: white;
}
.hvr-radial-out:hover:before, .hvr-radial-out:focus:before, .hvr-radial-out:active:before {
-webkit-transform: scale(2);
transform: scale(2);
}
<button class="hvr-radial-out">Test</button>
When click the button, there is a square border. I guess that you want to remove it. So add outline:0;
button {
background: #F0F1F2;
border: none;
cursor: pointer;
border-radius: 50%;
width: 100px;
height: 100px;
outline: 0;
}
.hvr-radial-out {
display: inline-block;
vertical-align: middle;
-webkit-transform: perspective(1px) translateZ(0);
transform: perspective(1px) translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
position: relative;
overflow: hidden;
background: #e1e1e1;
-webkit-transition-property: color;
transition-property: color;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
}
.hvr-radial-out:before {
content: "";
position: absolute;
z-index: -1;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #2098D1;
border-radius: 100%;
-webkit-transform: scale(0);
transform: scale(0);
-webkit-transition-property: transform;
transition-property: transform;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
.hvr-radial-out:hover, .hvr-radial-out:focus, .hvr-radial-out:active {
color: white;
}
.hvr-radial-out:hover:before, .hvr-radial-out:focus:before, .hvr-radial-out:active:before {
-webkit-transform: scale(2);
transform: scale(2);
}
<button class="hvr-radial-out">Test</button>
It might be because of border: none property you have used on button
You are using both border-radius: 50%; and border: 1px; which might be contradicting each other.
Please try with having border: 1px;

Change text on hover, CSS and html

I want to change the text when hovering over a speechbubble (already created) and set the text back when the mouse goes back. I have a "Welcome!" text set on the speechbubble and I want it to change to "Scroll down". The other issue is that I have set a css transformation on the speechbubble+welcome so that makes it harder..
Here's my code:
#welcome{
position:absolute;
top:50%;
left:50%;
width:auto;
height:auto;
-webkit-transform: translateX(-50%) translateY(-50%);
-moz-transform: translateX(-50%) translateY(-50%);
-ms-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
#speechbubble {
margin-left:110px;
width: 230px;
height: 80px;
line-height:80px;
text-align:center;
font-size:15px;
letter-spacing:2px;
-moz-box-shadow: 5px 5px 5px #888;
-webkit-box-shadow: 5px 5px 5px #888;
box-shadow: 5px 5px 5px #888;
font-family:{select:Title Font};
background: {color:Welcome background};
color:{color:Welcome text};
position: relative;
font-weight:bold;
}
#speechbubble:before {
content:"";
position: absolute;
right: 100%;
top: 26px;
width: 0;
height: 0;
border-top: 13px solid transparent;
border-right: 18px solid {color:Welcome background};
border-bottom: 13px solid transparent;
}
#welcome:hover #speechbubble{
-webkit-transition: all 0.7s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
margin-left:120px;
}
#welcome #speechbubble{
-webkit-transition: all 0.7s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
<div id="welcome">
<div id="speechbubble">Welcome!</div>
I've tried some tricks like adding a div for the second text and setting a css hover but it didn't work.. Can anyone help me? Thanks
You can use pseudo class :after and change its content on hover.
Like this:
#welcome {
position: absolute;
top: 50%;
left: 50%;
width: auto;
height: auto;
-webkit-transform: translateX(-50%) translateY(-50%);
-moz-transform: translateX(-50%) translateY(-50%);
-ms-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
#speechbubble {
margin-left: 110px;
width: 230px;
height: 80px;
line-height: 80px;
text-align: center;
font-size: 15px;
letter-spacing: 2px;
-moz-box-shadow: 5px 5px 5px #888;
-webkit-box-shadow: 5px 5px 5px #888;
box-shadow: 5px 5px 5px #888;
font-family: {
select: Title Font
}
;
background: {
color: Welcome background
}
;
color: {
color: Welcome text
}
;
position: relative;
font-weight:bold;
}
#speechbubble:after {
content: "Welcome!";
}
#speechbubble:before {
position: absolute;
right: 100%;
top: 26px;
width: 0;
height: 0;
border-top: 13px solid transparent;
border-right: 18px solid {
color: Welcome background
}
;
border-bottom: 13px solid transparent;
}
#welcome:hover #speechbubble:after {
content: "Scroll Down";
}
#welcome:hover #speechbubble {
-webkit-transition: all 0.7s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
margin-left: 120px;
}
#welcome #speechbubble {
-webkit-transition: all 0.7s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
<div id="welcome">
<div id="speechbubble"></div>
Using :after & :before try this, add this to your css:
#welcome:hover #speechbubble:after {
content: "Scroll Down";
}
#welcome:hover #speechbubble:before {
content: "";
}
#speechbubble:before {
content: "Welcome!";
}
then remove this right,top and position from your css:
#speechbubble:before {
content:"";
/*position: absolute;*/
/*right: 100%;*/
/*top: 26px;*/
width: 0;
height: 0;
border-top: 13px solid transparent;
border-right: 18px solid {color:Welcome background};
border-bottom: 13px solid transparent;
}
also remove the word Welcome:
<div id="welcome">
<div id="speechbubble"></div>
now this is the magic of CSS :)
Here is an example code using pseduo elements with data- attributes to
achieve the things:
#welcome {
position: absolute;
top: 50%;
left: 50%;
width: auto;
height: auto;
-webkit-transform: translateX(-50%) translateY(-50%);
-moz-transform: translateX(-50%) translateY(-50%);
-ms-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
body {
background: black;
}
/* .button */
#speechbubble {
display: inline-block;
position: relative;
margin: 1em;
padding: 0.67em;
border: 2px solid #FFF;
overflow: hidden;
text-decoration: none;
font-size: 2em;
outline: none;
color: #FFF;
background: transparent;
font-family: 'raleway', sans-serif;
}
#speechbubble span {
-webkit-transition: 0.6s;
-moz-transition: 0.6s;
-o-transition: 0.6s;
transition: 0.6s;
-webkit-transition-delay: 0.2s;
-moz-transition-delay: 0.2s;
-o-transition-delay: 0.2s;
transition-delay: 0.2s;
}
#speechbubble:before {
content: '';
position: absolute;
top: 0.67em;
left: 0;
width: 100%;
text-align: center;
opacity: 0;
-webkit-transition: .4s, opacity .6s;
-moz-transition: .4s, opacity .6s;
-o-transition: .4s, opacity .6s;
transition: .4s, opacity .6s;
}
/* :before */
#speechbubble:before {
content: attr(data-hover);
-webkit-transform: translate(-150%, 0);
-moz-transform: translate(-150%, 0);
-ms-transform: translate(-150%, 0);
-o-transform: translate(-150%, 0);
transform: translate(-150%, 0);
}
/* Span on :hover and :active */
#speechbubble:hover span {
opacity: 0;
-webkit-transform: scale(0.3);
-moz-transform: scale(0.3);
-ms-transform: scale(0.3);
-o-transform: scale(0.3);
transform: scale(0.3);
}
/*
We show :before pseudo-element on :hover
*/
#speechbubble:hover:before {
opacity: 1;
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
-o-transform: translate(0, 0);
transform: translate(0, 0);
-webkit-transition-delay: .4s;
-moz-transition-delay: .4s;
-o-transition-delay: .4s;
transition-delay: .4s;
}
<div id="welcome">
<div id="speechbubble" data-hover="Scroll Down"><span>Welcome!</span></div>
</div>
Here's very basic way to do it. Just put the text in some tags, and show/hide them on hover.
Also you can use the attr and :after features from css3.
#welcome{
position:absolute;
top:50%;
left:50%;
width:auto;
height:auto;
-webkit-transform: translateX(-50%) translateY(-50%);
-moz-transform: translateX(-50%) translateY(-50%);
-ms-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
#speechbubble {
margin-left:110px;
width: 230px;
height: 80px;
line-height:80px;
text-align:center;
font-size:15px;
letter-spacing:2px;
-moz-box-shadow: 5px 5px 5px #888;
-webkit-box-shadow: 5px 5px 5px #888;
box-shadow: 5px 5px 5px #888;
font-family:{select:Title Font};
background: {color:Welcome background};
color:{color:Welcome text};
position: relative;
font-weight:bold;
}
#speechbubble:before {
content:"";
position: absolute;
right: 100%;
top: 26px;
width: 0;
height: 0;
border-top: 13px solid transparent;
border-right: 18px solid {color:Welcome background};
border-bottom: 13px solid transparent;
}
#welcome:hover #speechbubble{
-webkit-transition: all 0.7s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
margin-left:120px;
}
#welcome #speechbubble .hover_on {
display: none;
}
#welcome #speechbubble .hover_off {
display: inline-block;
}
#welcome:hover #speechbubble .hover_on {
display: inline-block;
}
#welcome:hover #speechbubble .hover_off {
display: none;
}
#welcome #speechbubble{
-webkit-transition: all 0.7s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
<div id="welcome">
<div id="speechbubble"><p class="hover_off">Welcome!</p><p class="hover_on">Scroll down!</p></div>

Double underline effect CSS

I have this code from the Hover.css pack:
.hvr-underline-from-left{
display: inline-block;
vertical-align: middle;
-webkit-transform: translateZ(0);
transform: translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-osx-font-smoothing: grayscale;
position: relative;
overflow: hidden;
}
.hvr-underline-from-left::before {
content: "";
position: absolute;
z-index: -1;
left: 0;
right: 100%;
bottom: 0;
background: #0F9E5E;
height: 0.3em;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.2s;
transition-duration: 0.2s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
.hvr-underline-from-left:hover::before, .hvr-underline-from-left:focus::before, .hvr-underline-from-left:active::before {
right: 0;
}
What this does is that it adds a buttom border to a button that appeares from the left on hover.
But the effect i want is this, but multible times. So this should be added multible times with 0.1s delay every time, and an other color. How would i do this?
I tried using ::before(n) but it didn't work.
You can use after pseudo class to get the double underline effect.
//same as before class except for transition delay and bottom position you can adjust that as needed
.hvr-underline-from-left::after {
content: "";
position: absolute;
z-index: -1;
left: 0;
right: 100%;
bottom: 10px;
background: #0F9E5E;
height: 0.3em;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.1s;
transition-duration: 0.1s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
// on hover effect for after same as before class.
.hvr-underline-from-left:hover::after,
.hvr-underline-from-left:focus::after,
.hvr-underline-from-left:active::after {
right: 0;
}
//to add more
.hvr-underline-from-left .hvr-underline-from-left{
position:absolute;
height:100%;
width:100%;
background:transparent;
top:0;
left:0;
z-index:1000;
}
.hvr-underline-from-left .hvr-underline-from-left:after{
bottom:20px;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
}
.hvr-underline-from-left .hvr-underline-from-left:before{
bottom:30px;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
}
// and div tags look like this
<div class="hvr-underline-from-left">
<div class="hvr-underline-from-left">
</div>
</div>
****Please be careful once you give the inner container z-index and bring it to the front with 100% height and width any elements inside the main container might not be clickable.
Alternatively You can use css animation keyword for getting this multiple times underline effect with different color.and Adjust time according to your need. eg
.hvr-underline-from-left{
display: inline-block;
vertical-align: middle;
-webkit-transform: translateZ(0);
transform: translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-osx-font-smoothing: grayscale;
position: relative;
overflow: hidden;
}
.hvr-underline-from-left::before {
content: "";
position: absolute;
z-index: -1;
left: 0;
right: 100%;
bottom: 0;
height: 0.3em;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.2s;
transition-duration: 0.2s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
.hvr-underline-from-left:hover::before {
animation:colorUnderline 2s;
animation-fill-mode: forwards;
}
#keyframes colorUnderline{
0%{
right:100%;
background: #0F9E5E;
}
25%{
background: #0F9E5E;
right:0;
}
26%{
background: #8e44ad ;
right:100%;
}
50%{
background: #8e44ad ;
right:0;
}
51%{
background: #e74c3c ;
right:100%;
}
75%{
background: #e74c3c ;
right:0;
}
76%{
background: #f1c40f ;
right:100%;
}
100%{
right:0;
background: #f1c40f ;
}
}
<body>
<div class="hvr-underline-from-left">Test</div>
</body>

How to make partly bordered circle on top of another border?

I have a circle with some percentage covered border on top of another one with lower opacity. How to make this by CSS? I tried width: 20%, but for border-radius it does not work. I want to make this as on example image:
Also how to make ending of partly covered border with half-circle shape?
this is a purely css based progress bar in circle shape
in your html:
<div class="c100 p25">
<span>25%</span>
<div class="slice">
<div class="bar"></div>
<div class="fill"></div>
</div>
</div>
in css:
.c100.p25 .fill {
position: absolute;
border: 0.08em solid #307bbb;
width: 0.84em;
height: 0.84em;
clip: rect(0em, 0.5em, 1em, 0em);
border-radius: 50%;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
.c100 {
position: relative;
font-size: 120px;
width: 1em;
height: 1em;
border-radius: 50%;
float: left;
margin: 0 0.1em 0.1em 0;
background-color: #cccccc;
}
.c100 *,
.c100 *:before,
.c100 *:after {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.c100.center {
float: none;
margin: 0 auto;
}
.c100 > span {
position: absolute;
width: 100%;
z-index: 1;
left: 0;
top: 0;
width: 5em;
line-height: 5em;
font-size: 0.2em;
color: #cccccc;
display: block;
text-align: center;
white-space: nowrap;
-webkit-transition-property: all;
-moz-transition-property: all;
-o-transition-property: all;
transition-property: all;
-webkit-transition-duration: 0.2s;
-moz-transition-duration: 0.2s;
-o-transition-duration: 0.2s;
transition-duration: 0.2s;
-webkit-transition-timing-function: ease-out;
-moz-transition-timing-function: ease-out;
-o-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
.c100:after {
position: absolute;
top: 0.08em;
left: 0.08em;
display: block;
content: " ";
border-radius: 50%;
background-color: #f5f5f5;
width: 0.84em;
height: 0.84em;
-webkit-transition-property: all;
-moz-transition-property: all;
-o-transition-property: all;
transition-property: all;
-webkit-transition-duration: 0.2s;
-moz-transition-duration: 0.2s;
-o-transition-duration: 0.2s;
transition-duration: 0.2s;
-webkit-transition-timing-function: ease-in;
-moz-transition-timing-function: ease-in;
-o-transition-timing-function: ease-in;
transition-timing-function: ease-in;
}
.c100 .slice {
position: absolute;
width: 1em;
height: 1em;
clip: rect(0em, 1em, 1em, 0.5em);
}
.c100.p25 .bar {
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: rotate(90deg);
.c100:hover {
cursor: default;
}
.c100:hover > span {
width: 3.33em;
line-height: 3.33em;
font-size: 0.3em;
color: #307bbb;
}
.c100:hover:after {
top: 0.04em;
left: 0.04em;
width: 0.92em;
height: 0.92em;
}