I've got some buttons that have a CSS transition from black to yellow on hover, then return back to black. When clicked they make an AJAX call. They work nicely when I hover over them and click a mouse on all desktop browsers (naturally IE9 and lower ignore it), but on both iOS Safari, and the standard Android browser, the transition stays yellow after I have clicked the button. They do not return to the normal black state, like they do on a desktop system.
Any clues as to where I've gone wrong would be greatly appreciated. For those with a touch device, this Fiddle demonstrates the problem - http://jsfiddle.net/wpyz9whn/1/
CSS
a.button {
background-color: #000000;
color: #FFFFFF;
border: none;
text-decoration: none;
padding: 0px 10px;
display: block;
line-height: 24px;
font-weight: 700;
text-align: center;
transition: background 0.8s ease-out;
-moz-transition: background 0.8s ease-out;
-webkit-transition: background 0.8s ease-out;
text-transform: uppercase;
-webkit-appearance: none;
}
a.button:hover {
background: #ffcc00;
color: #000;
transition: background 0.2s ease-in;
-moz-transition: background 0.2s ease-in;
-webkit-transition: background 0.2s ease-in;
}
a.button:active {
background: #ff9c00;
transition: background 0s ease-in;
-moz-transition: background 0s ease-in;
-webkit-transition: background 0s ease-in;
}
a.button:focus {
outline: none;
}
HTML
<a class="button" onclick="return addToBasket(11628937,'/')">Add to Basket</a>
Related
Here is my website (currently building the mobile version). Here is the repository for the site.
button {
background-color: #fff;
border: 3px solid #efefef;
border-radius: 0.35em;
}
button:hover {
border-color: #49bf9d;
transition: border 0.2s ease-in-out;
}
I'm having issues with getting the border-color on my button elements to ease-out when hovering off the button element. The ease-in transition works just fine though.
Any Ideas?
Try this
add the transition property on button instead of hover
CSS
button
{
transition: border 0.2s ease-in-out !important;
}
hope this helps..
Add this to your CSS:
button {
transition: 0.4s ease-out all;
border: 4px solid black;
}
button:hover {
transition: 0.4s ease-in all;
border-color: red;
}
You can also add -moz-transition and -webkit-transition for older browsers.
the effect im after is the following: the button doesn't look like a button (ie border: none) and when clicked I want the focus outline to fade out after n seconds.
How can i achieve that?
Thanks
Simply adding a transition. Important to remember is that you need to transition the outline-color, not the outline.
.no-button {
margin:15px;
border:none;
}
.no-button:focus {
outline-color:transparent;
-webkit-transition: outline-color .7s ease-out 1s;
-moz-transition: outline-color .7s ease-out 1s;
-o-transition: outline-color .7s ease-out 1s;
transition: outline-color .7s ease-out 1s;
}
<button class="no-button">This is no button</button>
The first time (.7s) is the duration, the second one (1s) is the delay.
For getting such an effect border is better than outline and I played a little bit with it for you and the result is as follow:
button {
background: border-box linear-gradient(#841518, #4C0C00) no-repeat;
font-size: x-large;
font-family: Sans;
border: none;
transition: border-color 0.7s 0.2s;
border-width: 15px;
box-sizing: border-box;
height: 80px;
width: 220px;
display: inline-block;
}
button:focus {
border-style: solid;
border-color: transparent;
outline: none;
}
<button type="button">Click here</button>
So, I've taken over an internal project and the previous build had issues regarding the styling of check boxes. I have fixed the issue in Chrome which is fine for us as its the only installed browser here but when this goes live some modules will be available to customers which is where things get sticky. This is the code I am using to style the check boxes in Chrome:
input[type=checkbox] {
border-radius: 2px;
cursor: pointer;
margin-top: 1px;
border: 1px solid #gray;
background-color: white;
color: white;
white-space: nowrap;
overflow: hidden;
width: 20px;
height: 20px;
}
input[type=checkbox]:checked {
background-color: #3FAE2A;
border: 1px solid #3FAE2A;
}
input[type=checkbox] :hover {
border: 1px solid #3FAE2A;
-moz-transition: border-color 0.1s ease-out;
-o-transition: border-color 0.1s ease-out;
-webkit-transition: border-color 0.1s ease-out;
transition: border-color 0.1s ease-out;
}
Now currently this works in the sense that the check boxes are functional across all browsers but only styled in Chrome, is there any way for me to just use css to get this to work across IE and Firefox? If not, where should I be looking?
I can never get my CSS transitions to work on mouse out/off hover. It works fine on hover but not the other way around.
.btn {
border: 1px solid #5a5350;
background: #FFF;
color: inherit !important;
padding: 3px 10px;
display: inline-block;
font-weight: bold;
text-transform: uppercase;
-webkit-transition: background 0.5s ease-in-out;
-moz-transition: background 0.5s ease-in-out;
-o-transition: background 0.5s ease-in-out;
transition: background 0.5s ease-in-out;
}
.btn:hover {
color: #FFF !important;
background: #f79e43;
border: 1px solid #f79e43;
}
What's the problem with my code?
Thanks
Im having a problem inside of Chrome only, tested this inside of Opera, FF, Safari and it all works fine.
I know there was a bug with Chrome 17 with transitions on visited links so I even included that thought to be fix
There is still not animation for the transition on hover for border-bottom.
any clues? am I just not seeing something? I've read around and it all seems to be talking about the color of the text, while i'm trying to transition in the border-color.
I tried to animate in border-bottom from none to 1px solid #9ecd41 but found that in all browsers except firefox had a funky jagged animation where it kinda bounced.
any help would be awesome, attached is the code i'm working with.
Ok here is my html
<nav>
<ul class="nav">
<li>ABOUT</li>
<li>SERVICES</li>
<li>MEDIA</li>
<li>BLOG</li>
<li>CONTACT</li>
</ul>
</nav>
And here is my CSS
nav {
float: right;
height: auto;
width: auto;
padding: 25px;
}
ul.nav {
width: auto;
height: auto;
overflow: visible;
}
.nav > li {
display: inline-block;
margin-right: 20px;
}
.nav > li:last-child {
margin-right: 5px;
}
/* non-visited links: Chrome transition bug fix */
.nav > li > a:visited {
color: #ffffff;
letter-spacing: 1px;
text-decoration: none;
display: block;
font-family: "proxima-nova-condensed",sans-serif;
font-style: normal;
font-weight: 400;
font-size: 12px;
font-smooth: always;
-webkit-font-smoothing: antialiased;
padding-bottom: 5px;
border-bottom: 1px solid #333; /* CSS3 transition */
-webkit-transition: all .5s ease-in;
-moz-transition: all .5s ease-in;
-o-transition: all .5s ease-in;
-ms-transition: all .5s ease-in;
transition: all .2s ease-in;
}
/* visited links: Chrome transition bug fix */
.nav > li > a {
color: #ffffff;
letter-spacing: 1px;
text-decoration: none;
display: block;
font-family: "proxima-nova-condensed",sans-serif;
font-style: normal;
font-weight: 400;
font-size: 12px;
font-smooth: always;
-webkit-font-smoothing: antialiased;
padding-bottom: 5px;
border-bottom: 1px solid #333; /* CSS3 transition */
-webkit-transition: all .5s ease-in;
-moz-transition: all .5s ease-in;
-o-transition: all .5s ease-in;
-ms-transition: all .5s ease-in;
transition: all .2s ease-in;
}
.nav > li > a:hover {
border-bottom: 1px solid #9ecd41;
}
.nav > li > a:active {
border-bottom: 1px solid #f96d10;
}
Just styled the <li> the way I would of styled the li with widths/heights/padding/border etc and then just styled the link to fill the li and just styled the links colour and font properties. Chrome has small bug on border-bottom for link transitions
This aught to be an easy fix.
As far as I can see your problem lies by where you put the transition in.
With chrome it needs to be added to the at most parent.
Try adding it here:
.nav > li {
display: inline-block;
margin-right: 20px;
}
Also add the declaration for the -webkit- elements
for ex.
.nav > li {
display: inline-block;
margin-right: 20px;
-webkit-transition: all .5s ease-in;
-moz-transition: all .5s ease-in;
-o-transition: all .5s ease-in;
-ms-transition: all .5s ease-in;
transition: all .2s ease-in;
-webkit-transition-property: all;
-webkit-transition-duration: .5s;
-webkit-transition-timing-function: ease-in;
}
See if this works and if not I'll try to build something similar and work on a solution.
I had this problem with Bootstrap 4 navbar component. My menu links had border-bottom and starting from the second one, all were invisible during menu opening on mobile.
Fixed it with transform: rotate(0); on the element with the border-bottom.