Bootstrap - why is my button not responsive? - css

As you can see on the screenshot below, my pink button is not fully responsive: below a certain width it gets cut instead of resizing to remain within the viewport width.
What is the issue?
Many thanks
.btn {
background-color: #ff00bf;
border: 0 none;
border-radius: 25px;
box-shadow: 0 11px 22px rgba(34, 34, 34, 0.2);
color: #fff;
display: inline-block;
font-size: 1rem;
letter-spacing: 0.025em;
padding: 1.1em 2.28em 1em;
text-decoration: none;
transition: all 0.3s ease-out 0s;
}
.btn {
-moz-user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
cursor: pointer;
display: inline-block;
font-size: 14px;
font-weight: normal;
line-height: 1.42857;
margin-bottom: 0;
padding: 6px 12px;
text-align: center;
touch-action: manipulation;
vertical-align: middle;
white-space: nowrap;
}

The white-space: nowrap makes line-breaking impossible. Just remove it. Also I would set the max-width to 100%.
.btn {
background-color: #ff00bf;
border: 0 none;
border-radius: 25px;
box-shadow: 0 11px 22px rgba(34, 34, 34, 0.2);
color: #fff;
display: inline-block;
font-size: 1rem;
letter-spacing: 0.025em;
padding: 1.1em 2.28em 1em;
text-decoration: none;
transition: all 0.3s ease-out 0s;
}
.btn {
-moz-user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
cursor: pointer;
display: inline-block;
font-size: 14px;
font-weight: normal;
line-height: 1.42857;
margin-bottom: 0;
padding: 6px 12px;
text-align: center;
touch-action: manipulation;
vertical-align: middle;
max-width: 100%;
}

Related

How to fix uneven padding in a button

This is an insanely basic question but for the life of me I can't figure it out. I'm creating a button class and no matter what I do, there's extra space to the bottom and right of the text.
Tried altering line-height, border-box, margins, display, text-align and some others.
.button {
font-family: 'helvetica';
font-size: 16px;
color: #000;
margin: 0px;
position: relative;
letter-spacing: .4em;
text-transform: uppercase;
text-decoration: none;
color: $secondary-color;
border: 4px solid #000;
padding: .3em .75em;
margin: 0px;
text-align: center;
display: inline-block;
transition: all .25s ease-in-out;
-moz-transition: all .25s ease-in-out;
-webkit-transition: all .25s ease-in-out;
}
.button:hover {
color: #fff;
background-color: #000;
}
project
Just trying to get an evenly padded button that will resize to the text content.
this is happening because of letter-spacing:0.4em on your last letter to remove this wrap last letter in span with letter-spacing:0 like this:
.button {
font-family: 'helvetica';
font-size: 16px;
color: #000;
margin: 0px;
display:inline-block;
align-items:center;
position: relative;
letter-spacing: .4em;
text-transform: uppercase;
text-decoration: none;
border: 4px solid #000;
padding: .3em .75em;
margin: 0px;
text-align: center;
transition: all .25s ease-in-out;
-moz-transition: all .25s ease-in-out;
-webkit-transition: all .25s ease-in-out;
}
.button:hover {
color: #fff;
background-color: #000;
}
projec<span style="letter-spacing:0px;">t</span
Although the spec says letter-spacing shouldn't be added at the end of the line, it seems it is added regardless. You can use this padding instead to "undo" it:
padding: .3em calc(.74em - .4em) .3em .75em;
or equivalently
padding: .3em .35em .3em .75em;
.b1 {
border: 1px solid black;
padding: .3em .75em;
letter-spacing: .4em;
}
.b2 {
border: 1px solid black;
padding: .3em calc(.75em - .4em) .3em .75em;
letter-spacing: .4em;
}
<span class="b1">FOO</span>
<span class="b2">FOO</span>

Get mailchimp form (submit and email address ) on one line

I new to get "email address and submit" in the same line. How can I get this?
Here is my css:
.mc4wp-form-theme button, .mc4wp-form-theme input[type=submit], .mc4wp-form-theme input[type=button] {
display: inline-block;
padding: 8px 16px;
font-weight: 400;
line-height: 1.428571429;
text-align: center;
white-space: nowrap;
vertical-align: middle;
cursor: pointer;
border: 1px solid transparent;
border-radius: 2px;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
background: 0 0;
text-shadow: none;
filter: none;
height: auto;
width: auto;
}

Firefox renders poorly box shadow when rotation applied

I have an issue with Firefox rendering element to which is applied box shadow and rotation.
Is there any fix for this? I tried to apply rotateZ() backface visibility, no results.
.button{
backface-visibility: hidden;
padding-left: 1em;
padding-right: 1em;
line-height: 2.5em;
color: #FFF;
cursor: pointer;
min-width: 200px;
text-align: center;
text-decoration: none;
transition: all 100ms ease-in-out 0s;
background: #FFB600;
display: inline-block;
font-family: sans-serif;
font-size: 1.2em;
outline: 1px solid transparent;
box-shadow: 0.1em 0.1em 0px #DC6900, 0.2em 0.2em 1px #A32020;
transform:rotate(3deg);
padding-left: 1.5em;
padding-right: 1.5em;
background-color: #DC6900;
}
<a class="button">I am fancy button</a>
Firefox rendering 1
Just can add a border:
border: 1px solid #DC6900;
https://stackoverflow.com/a/9333891/1064270
.button{
backface-visibility: hidden;
padding-left: 1em;
padding-right: 1em;
line-height: 5.5em;
color: #FFF;
cursor: pointer;
min-width: 400px;
text-align: center;
text-decoration: none;
transition: all 100ms ease-in-out 0s;
background: #FFB600;
display: inline-block;
font-family: sans-serif;
font-size: 1.2em;
outline: 1px solid transparent;
box-shadow: 0.1em 0.1em 0px #DC6900, 0.2em 0.2em 1px #A32020;
padding-left: 1.5em;
transform:rotate(3deg);
padding-right: 1.5em;
background-color: #DC6900;
}
.with-border{border: 1px solid #DC6900;}
<a class="button">I am fancy button</a>
<br/>
<br/>
<a class="button with-border">I have a border</a>

Show text and icon in the middle of a button

I am coding a button with html5 and css3. Here are how it looks in different sizes:
You can see the icons are not in the middle. I know why it happens. But how can I set the icons in middle? Here is my code:
<i class="icon">a</i><span>start</span>
CSS:
.blue-pill {
display: block;
text-decoration: none;
width: 135px;
height: 50px;
margin-bottom: 15px;
position: relative;
background-color: #002032;
border: none;
color: #FFF;
text-transform: uppercase;
font-family: 'Open Sans Condensed', sans-serif;
font-weight: 700;
font-size: 14px;
padding: 0;
border-radius: 50px;
cursor: pointer;
z-index: 2;
text-align: center;
line-height: 50px;
-webkit-box-shadow: 0px 5px 0px #1488ae;
-moz-box-shadow: 0px 5px 0px #1488ae;
box-shadow: 0px 5px 0px #1488ae;
}
.blue-pill .icon {
display: inline-block;
margin: 0 5px;
color: #e57125;
font-size: 20px;
}
.blue-pill span {
display: inline-block;
}
.blue-pill.centered {
margin-left: auto;
margin-right: auto;
}
.blue-pill.inline {
display: inline-block;
margin-left: 5px;
margin-right: 5px;
}
I am using icon fonts for icons. Here is what I want:
add vertical-align:middle to .blue-pill .icon and .blue-pill span
Example

Button result not as desired

Why is it that when I test my page out on Chrome Canary emulating the iPad I get this result,
But when testing it out on the real device I get this
I'm trying to achieve the top one, but can't for some reason. Any ideas? Also is Chrome Canary reliable? Here's the CSS
#import url(http://fonts.googleapis.com/css?family=Open+Sans:300);
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #fff;
color: #7b8993;
font: 300 87.5%/1.5em 'Open Sans', sans-serif;
}
.form-wrapper {
padding-top: 10%;
border-radius: 2px;
margin: 50px auto;
position: relative;
width: 375px;
}
form {
padding: 30px 20px 0;
}
.form-item {
margin-bottom: 10px;
width: 100%;
}
.form-item input {
border: 1px solid #ccc;
border-radius: 2px;
color: #000;
font-family: 'Open Sans', sans-serif;
font-size: 1em;
height: 50px;
padding: 0 16px;
transition: background 0.3s ease-in-out;
width: 100%;
}
.form-item input:focus {
outline: none;
border-color: #9ecaed;
box-shadow: 0 0 10px #9ecaed;
}
.button-panel {
margin: 20px 0 0;
width: 100%;
}
.button-panel .button {
background: #009dff;
border: none;
border-radius: 2px;
color: #fff;
cursor: pointer;
height: 50px;
font-family: 'Open Sans', sans-serif;
font-size: 1.2em;
letter-spacing: 0.05em;
text-align: center;
text-transform: uppercase;
transition: background 0.3s ease-in-out;
width: 100%;
}
.button:hover {
background: #00c8ff;
}
#media only screen
and (max-width : 320px) {
.form-wrapper {
padding-top: 10%;
border-radius: 2px;
margin: 50px auto;
position: relative;
width: 320px;
}
}
.cent {
text-align: center;
color: #000;
}
.view {
text-align: center;
text-decoration: none;
color: #7b8993;
padding-top: 5px;
}
#ref {
text-align: center;
text-decoration: none;
color: #7b8993;
padding-top: 8px;
font-size: 16px;
}
#ref:hover {
text-align: center;
text-decoration: none;
color: #009dff;
-webkit-animation: hue 60s infinite linear;
padding-top: 8px;
font-size: 16px;
}
You need to add the following to the button element in order to remove the default styling.
-webkit-appearance: none;

Resources