Button disappearing briefly on hover - html

I have never run into this issue before. My input/button disappears for a brief moment when I hover over it.
Does anyone know why this would happen?
.button {
padding: 10px 12px;
border: 1px solid #BE1E2D;
border-radius: 2px;
box-sizing: border-box;
font-family: 'Muli', sans-serif;
font-size: 1.4rem;
color: #FFF;
background: linear-gradient(to bottom right, #BE1E2D, #981824);
text-transform: uppercase;
text-decoration: none;
transition: all .3s ease-in-out;-webkit-transition: all .3s ease-in-out;
cursor: pointer;
}
.button:hover {
background: #BE1E2D;
transition: all .3s ease-in-out;-webkit-transition: all .3s ease-in-out;
}
<input type="submit" value="Submit" class="button">

THIS POST IS FOR REFERENCE ONLY
As Turnip stated; the issue is that you're apply a transition: onto a gradient background so the background needs to be reset from null the first time the transition is effected.
You do not need to set a transition in the :hover state.
There's no need for transition all; only set transitons on the elements you actually want to change.
Removing the gradient issue (commented out) solves the problem.
You seem to have syntax issue: to right bottom is the correct syntax; not "to bottom right" it is [left|right] [top|bottom]
Therefore your question is an exact duplicate of Use CSS3 transitions with gradient backgrounds
Slowing down the transition and increasing the colour differences for clarity below:
.button {
padding: 10px 12px;
border: 1px solid #BE1E2D;
border-radius: 2px;
box-sizing: border-box;
font-family: 'Muli', sans-serif;
font-size: 1.4rem;
color: #FFF;
background: #981824;
/*background: linear-gradient(to right bottom, #BE1E2D, #99CC55);*/
text-transform: uppercase;
text-decoration: none;
transition: background 1s ease-in-out;
-webkit-transition: background 1s ease-in-out;
cursor: pointer;
}
.button:hover {
/*background: #BE1E2D;*/
background: #99CC55;
}
<input type="submit" value="Submit" class="button">
And with Gradients,
Partial Answer:
After my various fixes, now after the first instance where it loads from white, the gradient transition works correctly (on more Firefox) :
.button {
padding: 10px 12px;
border: 1px solid #BE1E2D;
border-radius: 2px;
box-sizing: border-box;
font-family: 'Muli', sans-serif;
font-size: 1.4rem;
color: #FFF;
background: linear-gradient(to right bottom, #BE1E2D, #99CC55);
text-transform: uppercase;
text-decoration: none;
transition: background 1s ease-in-out;
-webkit-transition: background 1s ease-in-out;
cursor: pointer;
}
.button:hover {
background: #BE1E2D;
}
<input type="submit" value="Submit" class="button">

Related

How to make a button with no border (gradient background) the same size as a button with a border (outline)?

I'm using Bootstrap v4 as the base for this code. Essentially, my problem is this: I'd like to make use of a gradient background for primary buttons, but we make use of outline as well. Because there's not really support for gradient borders, I'm not sure how best to ensure that both buttons end up being the same height & width with that missing 2px border on the primary buttons.
The above screenshot shows the problem. I did come up with this as one fix (which works great in Chrome):
background-color: var(--background) !important;
background-image: var(--gradient-background) !important;
border-width: 2px !important;
border-style: solid !important;
border-image-source: var(--gradient-background) !important;
border-image-slice: 1 !important;
Which (in Chrome) results in this:
which accurately depicts what I want my end result to look like. However, in Firefox, there's a weird bug which ends up like this:
And finally, setting the border to a transparent color adds a weird effect to the edges in both browsers:
Here's a Codepen that's messy but shows correctly the issue with transparent borders: https://codepen.io/anon/pen/ymvYQX
So I'm looking to do any of the following -
1) I would love some help figuring out how to get rid of the bug on Firefox so it renders exactly the same as it does on Chrome.
2) Alternatively, how else can I fix the original issue? Is there another way to force resizing of the buttons? What about a better alternative for the gradient border lines?
Thanks for your help!
You need to increase background-size to cover also the borders, else, you'll see it repeating:
.btn-primary:not(:disabled):not(.disabled):active, .btn-primary:not(:disabled):not(.disabled).active, .show > .btn-primary.dropdown-toggle {
color: #fff;
background-color: #074c81;
border-color: #074575;
}
.btn:not(:disabled):not(.disabled):active, .btn:not(:disabled):not(.disabled).active {
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
}
.btn-primary:hover {
color: #fff;
background-color: #08548d;
border-color: #074c81;
}
.btn:hover {
color: #58595b;
text-decoration: none;
}
button:not(:disabled), [type="button"]:not(:disabled), [type="reset"]:not(:disabled), [type="submit"]:not(:disabled) {
cursor: pointer;
}
.Button_root__2FLmr:hover, .Button_root__2FLmr:active, .Button_root__2FLmr:focus {
outline: none !important;
box-shadow: none !important;
}
.DrawerGroup_root___Kf5l button {
margin: 1rem 1rem 0 0 !important;
}
.btn-primary {
color: #fff;
background-color: #0a69b1;
border-color: #0a69b1;
box-shadow: none;
}
.btn {
display: inline-block;
font-weight: 400;
color: #58595b;
text-align: center;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: transparent;
border: 2px solid transparent;
padding: 0px 0.75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: 9px;
-webkit-transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
button, [type="button"], [type="reset"], [type="submit"] {
-webkit-appearance: button;
}
.Button_gradientBackground__2z0L9 {
background-color: #279DD9 !important;
background-image: linear-gradient(-60deg, #279DD9, #1169B2);
border: 2px solid transparent !important;
background-position:center;
background-size: calc(100% + 4px);/* or 101% is also fine */
}
.btn-outline-secondary {
color: #6c757d;
border-color: #6c757d;
}
.Button_root__2FLmr {
padding: 2px 1rem !important;
min-width: 7rem;
white-space: nowrap;
}
<div class="DrawerGroup_root___Kf5l">
<button type="button" class="Button_root__2FLmr Button_gradientBackground__2z0L9 btn btn-primary">save</button>
<button type="button" class="Button_root__2FLmr btn btn-outline-secondary">cancel</button>
</div>
The easiest way I know of to get "borderless" items that perfectly line up with your bordered items, is simply to use a transparent border.
border-color: rgba(0,0,0,0);
To handle the background issues, you can offset and grow the background image using a combination of background-size and background-position
E.g.
button {
background: linear-gradient(-60deg, #279DD9, #1169B2);
border: 2px solid #000;
width: 80px;
background-size: 84px;
background-position: -2px;
}
#b {
border-color: rgba(0, 0, 0, 0);
}
<button id="a">Button 1</button>
<button id="b">Button 2</button>
No need to hard code any value. All you need is to add background-origin: border-box;ref so that your background consider the border area too. By default it's padding-box so it will cover the padding area then will repeat inside border:
.btn-primary:not(:disabled):not(.disabled):active, .btn-primary:not(:disabled):not(.disabled).active, .show > .btn-primary.dropdown-toggle {
color: #fff;
background-color: #074c81;
border-color: #074575;
}
.btn:not(:disabled):not(.disabled):active, .btn:not(:disabled):not(.disabled).active {
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
}
.btn-primary:hover {
color: #fff;
background-color: #08548d;
border-color: #074c81;
}
.btn:hover {
color: #58595b;
text-decoration: none;
}
button:not(:disabled), [type="button"]:not(:disabled), [type="reset"]:not(:disabled), [type="submit"]:not(:disabled) {
cursor: pointer;
}
.Button_root__2FLmr:hover, .Button_root__2FLmr:active, .Button_root__2FLmr:focus {
outline: none !important;
box-shadow: none !important;
}
.DrawerGroup_root___Kf5l button {
margin: 1rem 1rem 0 0 !important;
}
.btn-primary {
color: #fff;
background-color: #0a69b1;
border-color: #0a69b1;
box-shadow: none;
}
.btn {
display: inline-block;
font-weight: 400;
color: #58595b;
text-align: center;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: transparent;
border: 2px solid transparent;
padding: 0px 0.75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: 9px;
-webkit-transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
button, [type="button"], [type="reset"], [type="submit"] {
-webkit-appearance: button;
}
.Button_gradientBackground__2z0L9 {
background-color: #279DD9 !important;
background-image: linear-gradient(-60deg, #279DD9, #1169B2);
border: 2px solid transparent !important;
background-position:center;
background-origin: border-box;
}
.btn-outline-secondary {
color: #6c757d;
border-color: #6c757d;
}
.Button_root__2FLmr {
padding: 2px 1rem !important;
min-width: 7rem;
white-space: nowrap;
}
<div class="DrawerGroup_root___Kf5l">
<button type="button" class="Button_root__2FLmr Button_gradientBackground__2z0L9 btn btn-primary">save</button>
<button type="button" class="Button_root__2FLmr btn btn-outline-secondary">cancel</button>
</div>
Related question for more detail: Why doesn't this radial-gradient complete the circle?

button text is blurred when css translated on hover

I'm using a button that moves up on hover. Check it out: https://jsfiddle.net/jmt3yk1v/. Unfortunately, button text becomes blurry when it is in the "hover" state. I've test it on different screens and the pattern seems to be that devices with devicePixelRatio around 1 and slightly above seem to have the most troubles. On Retina displays, there are no issues at all.
So if you are on non retina display, you will definitively see the blurry text. What would be the fix for this problem? Should I avoid css translates or can the blurriness be mitigated.
html:
Linky Button
css:
.bg{
background: linear-gradient(45deg, #275a77 0%, #38c195 100%);
}
.btn {
border-radius: 5px;
color: #fff;
cursor: pointer;
display: inline-block;
font-weight: 400;
letter-spacing: .5px;
margin: 0;
text-transform: uppercase;
-webkit-appearance: none;
}
.btn-default {
border: 0;
/* background: #2a7741; */
padding: 11px 30px;
font-size: 14px;
transition-duration: 0.2s;
transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);
}
.inline-block{
display: inline-block;
}
.btn:hover {
transform: translate3d(0,-3px,0);
box-shadow: 0 5px 8px #22222233;
}
If you use negative margin for animation, the blur seems to be gone
.btn:hover {
margin-top: -3px:
box-shadow: 0 5px 8px #22222233;
}

CSS styling works on Chrome but not on Firefox

In this case, i'm using bootstrap and added my own class for custom styling. my custom style works on Chrome but not in Mozilla.. here is the example:
element:
<input class="form-control en-input-label" id="source" name="source" value="Personal Contact" aria-required="true" aria-invalid="false" readonly />
on Chrome, it looks like this:
but on Firefox, the style doesn't really apply, and it looks like this:
here is the css comparison from dev tools..
Chrome:
but, Firefox can't read the en-input-label class and go with the default class instead.
can anyone explain what happens? why chrome is able to read the en-input-label but Firefox can't ?
EDIT:
Here are css for en-input-label
.form-control.en-input-label, .form-control.en-input-label:read-only {
border-left: none;
border-top: none;
border-right: none;
border-color: #e6e6e6;
padding: 0px;
display: inline-table;
height: 30px;
line-height: 30px;
box-shadow: none;
-webkit-box-shadow: none;
margin-bottom: 0px;
background: transparent;
font-size: 12px;
color: #777;
font-weight: 500;
}
any other css related to the elems is form-control from bootstrap:
.form-control {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.42857143;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 0;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
-webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
}
The reason is that Firefox needs a vendor prefix, so:
.form-control.en-input-label:-moz-read-only {

Equal padding on button not distributing equally

I was just having a small issue with applying equal padding to a button, I applied the following styles to it:
.btn-request-more-info {
background: #fff;
color: #6e2c91;
font-size: 18px;
padding: 0.5 2.5em;
border: 1px solid #fff;
font-weight: 900;
text-transform: uppercase;
border-radius: 10px;
border: 1px solid #fff;
-webkit-transition: all .3s;
-o-transition: all .3s;
transition: all .3s;
}
Now since the above doesn't work, I had to use a hack and reduce 1px from the bottom padding of the button:
.btn-request-more-info {
background: #fff;
color: #6e2c91;
font-size: 18px;
padding: 10px 2.5em 9px;
border: 1px solid #fff;
font-weight: 900;
text-transform: uppercase;
border-radius: 10px;
border: 1px solid #fff;
-webkit-transition: all .3s;
-o-transition: all .3s;
transition: all .3s;
}
10px above and 9px below, so why is it that 0.5em padding is not equally distributed?
P.S. to recreate the error, change the styles in the button to padding:0.5em 2em.
Difference in padding (I have used ruler to show visually the difference in padding distribution).
Padding above:
Padding below:
I have had this problem many times before, but never found a solution. Why might this be happening?
This can be because of line-height property of css. If you see the computed values(visual representation present at the end of style tab of developer tool) from developer tool both padding-top and bottom are same. But the difference you notice is not considering the line-height of the text. If you hover over your element from developer tool you'll see that box surrounding the text has some space below the text. The browser while applying padding consider this to be the part of the text and applies padding only around this box.
Try line-height:normal properties in css for button:
.btn-request-more-info {
background: #fff;
color: #6e2c91;
font-size: 18px;
padding: 10px 2.5em 10px;
border: 1px solid #fff;
font-weight: 900;
text-transform: uppercase;
border-radius: 10px;
border: 1px solid #fff;
line-height:normal;
-webkit-transition: all .3s;
-o-transition: all .3s;
transition: all .3s;
}

set input height to equal

I want to set the height of an input["text"] to equal to another input["submit"], but i do not understand what is going wrong. they move by some pixels.
This is my HTML code:
<input class="query" type="text" value="" placeholder="Search..."/> <input class="search" type="submit" value="Search" />
Css:
.query
{
width: 310px;
height: 28px;
font-size: 20px;
margin: 0px;
padding: 2px;
}
.search
{
background-color: #ff7700;
border-radius: 3px;
color: #ffffff;
border: 1px solid #ff7700;
font-size: 15px;
padding: 7px 10px 7px 10px;
margin: 0px;
font-weight: bold;
}
input[type=text], input[type=email], input[type=password], select, textarea {
-webkit-transition: all 0.30s ease-in-out;
-moz-transition: all 0.30s ease-in-out;
-ms-transition: all 0.30s ease-in-out;
-o-transition: all 0.30s ease-in-out;
outline: none;
border: 1px solid #006699;
border-radius: 3px;
}
input[type=text]:focus, input[type=email]:focus, input[type=password]:focus, select:focus, textarea:focus {
box-shadow: 0 0 5px rgba(81, 203, 238, 1);
border: 1px solid rgba(81, 203, 238, 1);
border-radius: 3px;
}
Any suggestions?
Thanks
I think, this would help you (Your Question is not clear, please provide HTML) -
Actually, both elements have save height. I don't think it's element height issue, it's vertical alignment issue(But not sure).
You can try vertical-align: top; Css property.
Note: It's might be give some different result in different-different scenario. You can see in Fiddle it's give correct output, but if you provide HTML it help us to understand your problem
.search {
background-color: #ff7700;
border-radius: 3px;
color: #ffffff;
border: 1px solid #ff7700;
font-size: 15px;
padding: 7px 10px 7px 10px;
margin: 0px;
font-weight: bold;
vertical-align: top;
}
Working Fiddle
Your question isn't very clear, but here might be what's going wrong:
I don't see height: 28px; under .search - that should make it the same height,
if you want all input fields to be the same height, add height: 28px under where you have input[type=text], input[type=email], input[type=password], select, text area
You also need to take margin, padding and border into account
As james said - proper indentation makes it much easier to read - you might have picked up on the problems ;)
Hope this helps,
Tom
Set .query class's height to 30px
.query
{
width: 310px;
height: 30px;
font-size: 20px;
margin: 0px;
padding: 2px;
}
here is a working example http://jsfiddle.net/9ZYCw/