html - Pure css gradually change text on hover -
i'm trying gradually change element's text while hovering, it's not working me.
i have css:
.author-details > div { display: inline-block; width: 30%; float: none !important; background-color: #1abc9c; color: #fff; padding: 2% 3% 2% 3%; border-radius: 7%; font-weight: normal; font-size: 16px; -webkit-transition: background 0.35s linear; -moz-transition: background 0.35s linear; -ms-transition: background 0.35s linear; -o-transition: background 0.35s linear; transition: background 0.35s linear; -webkit-box-shadow: 0px 5px 13px -8px rgba(0,0,0,0.45); -moz-box-shadow: 0px 5px 13px -8px rgba(0,0,0,0.45); box-shadow: 0px 5px 13px -8px rgba(0,0,0,0.45); } .author-details > div a:after { content: 'others'; } .author-details > div a:hover { background-color: #5dade2; } .author-details > div a:hover:after { -webkit-animation:fade-in 0.35s ease-in; } @-webkit-keyframes fade-in{ 0%{ opacity:1; top:0px; } 50%{ opacity:0; top:-5px; content: 'me'; } 100%{ opacity:1; top:-5px; }
}
and html:
<div><label>view as: </label> <a href ="#" onclick="return false" onmousedown="javascript:swapcontent('con1');"></a></div>
however when i'm hovering on element text doesn't change. want make change "me" when i'm hovering on , return "others" when i'm not. how can that?
here's jsfiddle: http://jsfiddle.net/2fgy912p/
code: http://codepen.io/anon/pen/qbdvob
this effect works using hover state set opacity of absolutely positioned elements' opacity on , off. , have transition applied fade in , out effect achieved.
jade styled html:
.widget span view as: input(type='checkbox',id='toggle') label.select(for='toggle') .default others .hovered
css:
* { margin: 0; padding: 0; } .widget { font-family: open sans; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } .widget span { vertical-align: top; line-height: 30px; } label.select { user-select: none; cursor: pointer; background-color: #3ce; color: #fff; border-radius: 2px; width: 60px; vertical-align: top; position: relative; height: 30px; display: inline-block; } label.select .default, label.select .hovered { transition: opacity 1s; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); opacity: 1; } label.select .hovered { opacity: 0; } label.select:hover { background-color: #36f; } label.select .default { opacity: 1; } label.select .hovered { opacity: 0; } label.select:hover .default { opacity: 0; } label.select:hover .hovered { opacity: 1; }
Comments
Post a Comment