CSS Hover Effects Persisting When I Don't Want It To - css

I've got a div styled to be a circle with an image and some text centered inside of it.
Without hovering, the circle and image are shown while the text is transparent.
When hovering, the circle border starts flashes (webkit animation), the image's opacity is lowered, and the text becomes visible.
When writing/testing this code in Firefox, everything works as desired, but on Chrome, the changes from the hover effect persist and I don't want them to (namely, the image opacity stays lowered, and the text remains visible. Continuing to hover on the div, however, makes the border flash as intended.
I've got all the correct webkit/moz/ms/o transitions and animations, but I can't seem to figure out what's going wrong (or if this is just one of the deficiencies that comes from using Chrome).
My code for the div and all its elements is:
<div class='players'>
<div class='row'>
<div class='span6'>
<div class='matchup'>
<p class='team'>SOMETEAMNAME</p>
<p class='name'>SOMENAME</p>
<img src='SOMEIMAGE'>
</div>
</div>
</div>
</div>
My CSS code:
.matchup {
width: 250px;
height: 250px;
background: transparent;
border: 1px solid #ff6600;
border-radius: 125px;
display: block;
margin-left: auto;
margin-right: auto;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
-o-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: 0.5s ease;
-moz-transition: 0.5s ease;
-ms-transition: 0.5s ease;
-o-transition: 0.5s ease;
transition: 0.5s ease;
}
.matchup img {
position: static;
margin-top: -22%;
opacity: 1;
-webkit-transition: 0.5s ease;
-moz-transition: 0.5s ease;
-ms-transition: 0.5s ease;
-o-transition: 0.5s ease;
transition: 0.5s ease;
}
.matchup p {
font-family: 'Lobster', cursive;
position: relative;
text-align: center;
top: 50%;
color: transparent;
-webkit-transition: 0.5s ease;
-moz-transition: 0.5s ease;
-ms-transition: 0.5s ease;
-o-transition: 0.5s ease;
transition: 0.5s ease;
}
.team {
font-size: 25px;
}
.name {
font-size: 45px;
}
.map {
font-size: 15px;
margin-top: -70%;
}
.matchup:hover {
-webkit-animation: matchup-active 1s infinite;
-moz-animation: matchup-active 1s infinite;
-ms-animation: matchup-active 1s infinite;
-o-animation: matchup-active 1s infinite;
animation: matchup-active 1s infinite;
p {
color: #ff6600;
}
img {
opacity: 0.2;
}
}
#-webkit-keyframes matchup-active {
0% {
border: 1px solid #ff6600;
}
50% {
border: 1px solid transparent;
}
100% {
border: 1px solid #ff6600;
}
}
#-moz-keyframes matchup-active {
0% {
border: 1px solid #ff6600;
}
50% {
border: 1px solid transparent;
}
100% {
border: 1px solid #ff6600;
}
}
#-o-keyframes matchup-active {
0% {
border: 1px solid #ff6600;
}
50% {
border: 1px solid transparent;
}
100% {
border: 1px solid #ff6600;
}
}
#keyframes matchup-active {
0% {
border: 1px solid #ff6600;
}
50% {
border: 1px solid transparent;
}
100% {
border: 1px solid #ff6600;
}
}
EDIT:
Updated with a jsfiddle: http://jsfiddle.net/sicophrenic/qvJ94/
It's not styled perfectly (i.e. images and stuff aren't centered), but the problem I'm having shows up (in Chrome and works fine in Firefox).

on .matchup add color:transparent;
on .matchup:hover add color: #ff6600;
on .matchup p add color: inherit;
because .matchup:hover p is not a valid selector.
here is a fiddle

Related

Button CSS Hyperlink Using DIV

I am trying to use below buttons for my web pages. How to use it for setting hyper link in these buttons ?
#import url('http://fonts.googleapis.com/css?family=Roboto+Condensed');
.preserve-3d {
transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
}
body {
padding: 0;
margin: 0;
border: 0;
overflow-x: none;
background-color: #ffffff;
font-family: Roboto Condensed, sans-serif;
font-size: 12px;
font-smooth: always;
-webkit-font-smoothing: antialiased;
}
.back {
width: 33%;
height: 200px;
float: left;
background-color: #eeeeee;
border: 10px;
border-color: #ffffff;
border-style: solid;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
counter-increment: bc;
padding: 0px 5px 5px 5px;
}
.back:before {
content: counter(bc) "_";
position: absolute;
padding: 10px;
}
#media screen and (max-width: 1260px) {
.back {
width: 50%;
}
}
#media screen and (max-width: 840px) {
.back {
width: 100%;
}
}
.button_base {
margin: 0;
border: 0;
font-size: 18px;
position: relative;
top: 50%;
left: 50%;
margin-top: -25px;
margin-left: -100px;
width: 200px;
height: 50px;
text-align: center;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-user-select: none;
cursor: default;
}
.button_base:hover {
cursor: pointer;
}
/* ### ### ### 01 */
.b01_simple_rollover {
color: #000000;
border: #000000 solid 1px;
padding: 10px;
background-color: #ffffff;
}
.b01_simple_rollover:hover {
color: #ffffff;
background-color: #000000;
}
/* ### ### ### 02 */
.b02_slide_in {
overflow: hidden;
border: #000000 solid 1px;
}
.b02_slide_in div {
position: absolute;
text-align: center;
width: 100%;
height: 50px;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
padding: 10px;
}
.b02_slide_in div:nth-child(1) {
color: #000000;
background-color: #ffffff;
}
.b02_slide_in div:nth-child(2) {
background-color: #000000;
transition: top 0.1s ease;
-webkit-transition: top 0.1s ease;
-moz-transition: top 0.1s ease;
top: -50px;
}
.b02_slide_in div:nth-child(3) {
color: #ffffff;
transition: opacity 0.1s ease;
-webkit-transition: opacity 0.1s ease;
-moz-transition: opacity 0.1s ease;
opacity: 0;
}
.b02_slide_in:hover div:nth-child(2) {
top: 0px;
transition: top 0.1s ease;
-webkit-transition: top 0.1s ease;
-moz-transition: top 0.1s ease;
}
.b02_slide_in:hover div:nth-child(3) {
opacity: 1;
transition: opacity 0.1s ease;
-webkit-transition: opacity 0.1s ease;
-moz-transition: opacity 0.1s ease;
}
/* ### ### ### 03 */
.b03_skewed_slide_in {
overflow: hidden;
border: #000000 solid 1px;
}
.b03_skewed_slide_in div {
position: absolute;
text-align: center;
width: 100%;
height: 50px;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
padding: 10px;
}
.b03_skewed_slide_in div:nth-child(1) {
color: #000000;
background-color: #ffffff;
}
.b03_skewed_slide_in div:nth-child(2) {
background-color: #000000;
width: 230px;
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
transform: translate(-250px, 0px) skewX(-30deg);
-webkit-transform: translate(-250px, 0px) skewX(-30deg);
-moz-transform: translate(-250px, 0px) skewX(-30deg);
}
.b03_skewed_slide_in div:nth-child(3) {
color: #ffffff;
left: -200px;
transition: left 0.2s ease;
-webkit-transition: left 0.2s ease;
-moz-transition: left 0.2s ease;
}
.b03_skewed_slide_in:hover div:nth-child(2) {
transition: all 0.5s ease;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
transform: translate(-15px, 0px) skewX(-30deg);
-webkit-transform: translate(-15px, 0px) skewX(-30deg);
-moz-transform: translate(-15px, 0px) skewX(-30deg);
}
.b03_skewed_slide_in:hover div:nth-child(3) {
left: 0px;
transition: left 0.30000000000000004s ease;
-webkit-transition: left 0.30000000000000004s ease;
-moz-transition: left 0.30000000000000004s ease;
}
/* ### ### ### 04 */
.b04_3d_tick {
perspective: 500px;
-webkit-perspective: 500px;
-moz-perspective: 500px;
perspective-origin: center top;
-webkit-perspective-origin: center top;
-moz-perspective-origin: center top;
}
.b04_3d_tick div {
position: absolute;
text-align: center;
width: 100%;
height: 50px;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
padding: 10px;
border: #000000 solid 1px;
}
.b04_3d_tick div:nth-child(1) {
color: #000000;
background-color: #ffffff;
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
}
.b04_3d_tick div:nth-child(2) {
color: #ffffff;
background-color: #000000;
transform: rotateX(90deg);
-webkit-transform: rotateX(90deg);
-moz-transform: rotateX(90deg);
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
transform-origin: left top;
-webkit-transform-origin: left top;
-moz-transform-origin: left top;
}
.b04_3d_tick:hover div:nth-child(1) {
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
background-color: rgba(0, 0, 0, 0.5);
}
.b04_3d_tick:hover div:nth-child(2) {
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
-moz-transform: rotateX(0deg);
}
/* ### ### ### 05 */
.b05_3d_roll {
perspective: 500px;
-webkit-perspective: 500px;
-moz-perspective: 500px;
}
.b05_3d_roll div {
position: absolute;
text-align: center;
width: 100%;
height: 50px;
padding: 10px;
border: #000000 solid 1px;
pointer-events: none;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
.b05_3d_roll div:nth-child(1) {
color: #000000;
background-color: #000000;
transform: rotateX(90deg);
-webkit-transform: rotateX(90deg);
-moz-transform: rotateX(90deg);
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
transform-origin: 50% 50% -25px;
-webkit-transform-origin: 50% 50% -25px;
-moz-transform-origin: 50% 50% -25px;
}
.b05_3d_roll div:nth-child(2) {
color: #000000;
background-color: #ffffff;
transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
-moz-transform: rotateX(0deg);
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
transform-origin: 50% 50% -25px;
-webkit-transform-origin: 50% 50% -25px;
-moz-transform-origin: 50% 50% -25px;
}
.b05_3d_roll:hover div:nth-child(1) {
color: #ffffff;
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
transform: rotateX(0deg);
-webkit-transform: rotateX(0deg);
-moz-transform: rotateX(0deg);
}
.b05_3d_roll:hover div:nth-child(2) {
background-color: #000000;
transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
transform: rotateX(-90deg);
-webkit-transform: rotateX(-90deg);
-moz-transform: rotateX(-90deg);
}
/* ### ### ### 06 */
.b06_3d_swap {
perspective: 500px;
-webkit-perspective: 500px;
-moz-perspective: 500px;
transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
}
<div class="back">
<div class="button_base b02_slide_in">
<div>01_Button</div>
<div></div>
<div>01_Button</div>
</div>
</div>
<div class="back">
<div class="button_base b03_skewed_slide_in">
<div>01_Button</div>
<div></div>
<div>01_Button</div>
</div>
</div>
<div class="back">
<div class="button_base b04_3d_tick">
<div>01_Button</div>
<div>01_Button</div>
</div>
</div>
<div class="back">
<div class="button_base b05_3d_roll">
<div>02_Button</div>
<div>01_Button</div>
</div>
</div>
I want to use these buttons as link for download button. How to use it for setting hyper link in these buttons ? Any help will be appreciated.
You can replace button with an a tag and style it like a button, like this:
01_Button
EDIT: Sorry I didn't see you were using divs. Add you link inside the div, like this:
<div class="button-style">01_Button</div>
<div class="button_base b02_slide_in">
<div>01_Button</div>
<div></div>
<div><a class="link" href="#">01_Button</a></div>
</div>
<style>
.link:hover
{
color:#fff;
text-decoration: none;
}
</style

drop-down menu closing issue in wordpress?

I already succeed to added the transition effect when hover the cursor to drop-down menu (click the "M" logo) in my own wordpress theme but when the cursor being away from drop-down menu don't show the transition effect when closing. You can check out my own theme on this link for further info.
Here drop-down css style:
.dropdown-menu {
border-bottom-right-radius: 77px;
border-bottom-left-radius: 77px;
/* background: url(img/submenu.png) no-repeat scroll right/ 91% 100%; */
position: absolute;
height:0;
top: 100%;
left: 0;
z-index: 1000;
display: none;
float: left;
min-width: 153px;
padding: 1px 0;
margin: 2px 0 0 0;
list-style: none;
font-size: 14px;
text-align: center;
background-color: transparent!important;
border: 1px solid #ccc;
border: 1px solid rgba(0,0,0,0.15);
background-clip: padding-box;
opacity: 0;
top: 35px;
visibility: hidden;
-webkit-transition:height 300ms ease-in;
-moz-transition:height 300ms ease-in;
-ms-transition: height 300ms ease-in;
-o-transition:height 300ms ease-in;
transition:height 300ms ease-in;
overflow: hidden;
}
.navbar-nav li:hover .dropdown-menu {
opacity: 1;
top: 105px;
visibility: visible;
height:300px;
}
So How I can add the transition effect when drop-down menu closing?
Instead of transitioning only the height you could try
-webkit-transition: all 300ms ease-in;
-moz-transition: all 300ms ease-in;
-ms-transition: all 300ms ease-in;
-o-transition: all 300ms ease-in;
transition: all 300ms ease-in;

Opacity transition not working in both directions

I expected this to transition when entering and leaving the dimmed state but it only transitions when leaving. How can I make the transition work when entering it? I also tried ease-in and ease-out but these don't seem to make a difference.
.is-dimmed-unless-active:not(:active):not(:focus):not(:hover) {
opacity: .5;
transition: opacity .5s ease-in-out;
}
Live example of problem http://codepen.io/ryanve/pen/doKdgW
Because you need to define the transition on .card:
.card {
transition: opacity .5s ease-in-out;
}
Instead on:
.is-dimmed-unless-active:not(:active):not(:focus):not(:hover) {
transition: opacity .5s ease-in-out;
}
Change you css to this:
.is-dimmed-unless-active {
transition: opacity .5s ease-in-out;
opacity: 1;
}
.is-dimmed-unless-active:hover {
opacity: .5;
}
.card {
width: 60%;
margin: 1em auto;
padding: 1em;
color: crimson;
border: 3px dotted crimson;
}
body {
font-family: sans-serif;
background: white;
}

Align <ul> <li> elements to the left

I'm having trouble aligning li elements to the left on tabs, as they are centered. I was wondering if someone could help me out.
I've tried a few things but always end up breaking the code.
Also, as a plus, the effects for fadein on divs don't seem to work on opera and firefox.
Here's the jsfiddle: http://jsfiddle.net/guisasso/6f6PY/
CSS
.tabs {
border-bottom:3px #f2f2f2 solid;
}
.tabs li {
list-style:none;
display:inline;
color:#08c;
}
.tabs a {
padding:5px 20px;
display:inline-block;
background:#ffffff;
text-decoration:none;
color:#08c;
top: 3px;
font-size: 22px;
line-height: 140%;
padding-top: 10px;
background: #ffffff;
box-sizing: border-box;
position: relative;
border-radius: 4px 4px 0 0;
margin-bottom:3px;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
.tabs a.active {
background: #ffffff;
border-bottom:3px orange solid;
color:#000000;
top:0px;
}
.tabs a:hover {
background: #f2f2f2;
top: 0px;
border-bottom:3px orange solid;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
#tab1, #tab2, #tab3, #tab4 {
animation: fadein 1s;
-moz-animation: fadein 1s; /* Firefox */
-webkit-animation: fadein 1s; /* Safari and Chrome */
-o-animation: fadein 1s; /* Opera */
}
#keyframes fadein {
from {
opacity:0;
}
to {
opacity:1;
}
}
#-moz-keyframes fadein { /* Firefox */
from {
opacity:0;
}
to {
opacity:1;
}
}
#-webkit-keyframes fadein { /* Safari and Chrome */
from {
opacity:0;
}
to {
opacity:1;
}
}
#-o-keyframes fadein { /* Opera */
from {
opacity:0;
}
to {
opacity: 1;
}
}
HTML
<ul class="tabs">
<li><a href='#tab1'>Tab #1</a></li>
<li><a href='#tab2'>Tab #2</a></li>
<li><a href='#tab3'>Tab #3</a></li>
<li><a href='#tab4'>Tab #4</a></li>
</ul>
<div id="tab1">111111111111111 11111111111111111 1111111111111111111 1111111111111</div>
<div id="tab2">222222222222222 22222222222222222 2222222222222222222 2222222222222</div>
<div id="tab3">333333333333333 33333333333333333 3333333333333333333 3333333333333</div>
<div id="tab4">444444444444444 44444444444444444 4444444444444444444 4444444444444</div>
Thanks
Add to .tabs:
padding-left: 0;
Change in .tabs a:
padding: 5px 20px;
to
padding: 5px 20px 5px 0;
It doesn't get any lefter than that.
Fiddle: http://jsfiddle.net/PRL5H/

CSS3 animate border color

I want to animate borders of an element using CSS3, whether it's in hover state or normal state. Can someone provide me a code snippet for this or can guide?
I can do this using jQuery but looking for some pure CSS3 solution.
You can use a CSS3 transition for this. Have a look at this example:
http://jsfiddle.net/ujDkf/1/
Here is the main code:
#box {
position : relative;
width : 100px;
height : 100px;
background-color : gray;
border : 5px solid black;
-webkit-transition : border 500ms ease-out;
-moz-transition : border 500ms ease-out;
-o-transition : border 500ms ease-out;
transition : border 500ms ease-out;
}
#box:hover {
border : 10px solid red;
}
You can try this also...
button {
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;
vertical-align: middle;
position: relative;
}
button::before, button::after {
box-sizing: inherit;
content: '';
position: absolute;
width: 100%;
height: 100%;
}
.draw {
-webkit-transition: color 0.25s;
transition: color 0.25s;
}
.draw::before, .draw::after {
border: 2px solid transparent;
width: 0;
height: 0;
}
.draw::before {
top: 0;
left: 0;
}
.draw::after {
bottom: 0;
right: 0;
}
.draw:hover {
color: #60daaa;
}
.draw:hover::before, .draw:hover::after {
width: 100%;
height: 100%;
}
.draw:hover::before {
border-top-color: #60daaa;
border-right-color: #60daaa;
-webkit-transition: width 0.25s ease-out, height 0.25s ease-out 0.25s;
transition: width 0.25s ease-out, height 0.25s ease-out 0.25s;
}
.draw:hover::after {
border-bottom-color: #60daaa;
border-left-color: #60daaa;
-webkit-transition: border-color 0s ease-out 0.5s, width 0.25s ease-out 0.5s, height 0.25s ease-out 0.75s;
transition: border-color 0s ease-out 0.5s, width 0.25s ease-out 0.5s, height 0.25s ease-out 0.75s;
}
<section class="buttons">
<button class="draw">Draw</button>
</section>
If you need the transition to run infinitely, try the below example:
#box {
position: relative;
width: 100px;
height: 100px;
background-color: gray;
border: 5px solid black;
display: block;
}
#box:hover {
border-color: red;
animation-name: flash_border;
animation-duration: 2s;
animation-timing-function: linear;
animation-iteration-count: infinite;
-webkit-animation-name: flash_border;
-webkit-animation-duration: 2s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-moz-animation-name: flash_border;
-moz-animation-duration: 2s;
-moz-animation-timing-function: linear;
-moz-animation-iteration-count: infinite;
}
#keyframes flash_border {
0% {
border-color: red;
}
50% {
border-color: black;
}
100% {
border-color: red;
}
}
#-webkit-keyframes flash_border {
0% {
border-color: red;
}
50% {
border-color: black;
}
100% {
border-color: red;
}
}
#-moz-keyframes flash_border {
0% {
border-color: red;
}
50% {
border-color: black;
}
100% {
border-color: red;
}
}
<div id="box">roll over me</div>
A bit late to this one but...
This is what I do:
.class {
color: tomato;
border: 10px solid currentColor;
transition: color 250ms linear;
// not part of solution just layout
width: 100px;
height: 100px;
display: flex;
justify-content: center;
align-items: center;
font-size: 2rem;
text-transform: uppercase;
}
.class:hover {
color: rebeccapurple;
}
<div class='class' >color way</div>

Resources