Equal padding on button not distributing equally - html

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;
}

Related

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;
}

Button disappearing briefly on hover

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">

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 {

Adding a border to input with Bootstrap

I am currently working on a website with a complex CSS file. I have added a new feature, but I can't seem to edit an input tab that I have due to other styling affecting it. Essentially I am trying to over-ride a certain property.
CSS
textarea, input[type="number"]{
background-color: #ffffff;
border: 0 solid #CCCCCC;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.035) inset;
transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s;
}
select, input[type="number"] {
border-radius: 2px 2px 2px 2px;
color: #555555;
display: inline-block;
height: 37px;
font-size: 14px;
line-height: 15px;
margin-bottom: 0px;
padding: 2px 6px;
vertical-align: middle;
}
select, textarea, input[type="number"]
color: #626c72;
display: inline-block;
font-size: 14px;
line-height: 20px;
margin-bottom: 10px;
padding: 4px 6px;
vertical-align: middle;
box-shadow: 1px 1px 8px rgba(0,0,0,0.05);
width: 100%;
}
.target {
border: 0;
}
HTML
<div class="container">
<div class="row">
<div class="form-group col-sm-6">
<label for="Label1">Label1:</label>
<input class="form-control target" step="any" type="number" min="0" max="24"></input>
</div>
</div>
</div>
What I am trying to do is have is override border: 0 solid #CCCCCC; from the first selector and make it look like the default bootstrap input for the .target input . I don't want it to affect all other inputs in my application. I only want it to affect the html you see above. I thought my last styling .target selector would do the trick, but it doesn't. My jsFiddle is here. I want the default bootstrap border/outline for my input. As you can tell its not there right now.
You can use the CSS :not selector if you don't want your custom CSS to apply to that specific input:
textarea, input[type="number"]:not(.target) {
background-color: #ffffff;
border: 0 solid #CCCCCC;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.035) inset;
transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s;
}
select, input[type="number"]:not(.target) {
border-radius: 2px 2px 2px 2px;
color: #555555;
display: inline-block;
height: 37px;
font-size: 14px;
line-height: 15px;
margin-bottom: 0px;
padding: 2px 6px;
vertical-align: middle;
}
Bootply
You can also use:
input.target {
border: 0;
}
or
input[type="number"].target {
border: 0;
}

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/