Responsive button - With name and number - html

I tried to create a corresponding button that contains the name of the button and a number.
I used padding to separate the button name from the number, however when the number is very high, that same number overlaps the button name.
Is there a way to center the name on the button and make the button fully responsive regardless of the number displayed?
DEMO
Html
<div class="d-flex justify-content-md-center flex-nowrap" style="margin-top:50px">
<a style="color: #51CC8B;" class="btnP">Prepared
<span class="nav-link btn-glyphicon1">1500</span>
</a>
</div>
Css
.btnP {
padding-right: 50px;
padding-left: 8px;
height: 24px;
transition: all 0.3s ease 0s;
cursor: pointer;
white-space: nowrap;
position: relative;
text-decoration: none;
display: flex;
align-items: center;
margin-right: 16px;
text-align: center;
font-weight: bold;
font-size: 13px;
font-family: 'Noto Sans', sans-serif;
line-height: 6px;
letter-spacing: 0;
color: #51CC8B;
-ms-border-radius: 16px;
-o-border-radius: 16px;
-moz-border-radius: 16px;
-webkit-border-radius: 16px;
border-radius: 16px;
border-width: none;
background: #EDFAF3;
outline: none;
}
.btn-glyphicon1 {
padding: 8px;
line-height: 6px;
text-align: center;
border-radius: 16px;
right: 0;
position: absolute;
background: #DDF6E9 0% 0% no-repeat padding-box;
font-size: 13px;
font-family: 'Noto Sans', sans-serif;
letter-spacing: 0;
color: #51CC8B;
}
PROBLEM
As you can see in the image, the number overlaps the name :( I want the text to always remain centered on the button and the width to adjust according to the size of the number.
Can someone help me?

.btnP {
padding-right: 50px;
padding-left: 8px;
height: 24px;
transition: all 0.3s ease 0s;
cursor: pointer;
white-space: nowrap;
position: relative;
text-decoration: none;
display: flex;
align-items: center;
justify-content:center;
margin-right: 16px;
text-align: center;
font-weight: bold;
font-size: 13px;
font-family: 'Noto Sans', sans-serif;
line-height: 6px;
letter-spacing: 0;
color: #51CC8B;
-ms-border-radius: 16px;
-o-border-radius: 16px;
-moz-border-radius: 16px;
-webkit-border-radius: 16px;
border-radius: 16px;
border-width: none;
background: #EDFAF3;
outline: none;
}
.btn-glyphicon1 {
padding: 8px;
line-height: 6px;
border-radius: 16px;
align-items:center;
background: #DDF6E9 0% 0% no-repeat padding-box;
font-size: 13px;
font-family: 'Noto Sans', sans-serif;
margin-left:20px;
color: #51CC8B;
}
<div class="d-flex justify-content-md-center flex-nowrap" style="margin-top:50px">
<a style="color: #51CC8B;" class="btnP">Prepared
<span class="nav-link btn-glyphicon1">1500</span>
</a>
</div>

Related

Button overflow x in line when the screen is mobile

I have a line with buttons. When I reduce the screen I want all the buttons to remain in line and work as an overflow-x: scroll.
My problem is that when reducing the screen, the overflow x works, but the button comes out of the screen.
How can I solve this? Thanks
DEMO
CODE
<div class="row justify-content-center flex-nowrap myrow" style="margin-top: 160px;">
<a style="color: #51CC8B;" class="btnP">PRG
<span class="nav-link btn-glyphicon1">100</span>
</a>
<a style="color: #4981C2;" class="btnR">TRV
<span class="nav-link btn-glyphicon">50</span>
</a>
<a style="color: #4981C2;" class="btnD">DN
<span class="nav-link btn-glyphicon">21</span>
</a>
</div>
Problem
removed row class
and
added d-flex justify-content-md-center classes
and added below css
.myrow {
overflow-x: auto;
}
.myrow {
overflow-x: auto;
}
.btn-glyphicon {
padding: 8px;
line-height: 6px;
text-align: center;
border-radius: 16px;
background: #ffffff;
right: 0;
position: absolute;
background: #DBE7F4 0% 0% no-repeat padding-box;
font-size: 13px;
font-family: 'Noto Sans', sans-serif;
letter-spacing: 0;
color: #4981C2;
}
.btn-glyphicon1 {
padding: 8px;
line-height: 6px;
text-align: center;
border-radius: 16px;
background: #ffffff;
right: 0;
position: absolute;
background: #DDF6E9 0% 0% no-repeat padding-box;
font-size: 13px;
font-family: 'Noto Sans', sans-serif;
letter-spacing: 0;
color: #51CC8B;
}
.btnR {
padding-right: 50px;
padding-left: 8px;
height: 24px;
font-size: 13px;
transition: all 0.3s ease 0s;
cursor: pointer;
white-space: nowrap;
position: relative;
text-decoration: none;
display: inline-block;
display: flex;
align-items: center;
margin-right: 16px;
text-align: center;
font-weight: bold;
font-size: 13px;
font-family: 'Noto Sans', sans-serif;
line-height: 6px;
letter-spacing: 0;
color: #4981C2;
-ms-border-radius: 16px;
-o-border-radius: 16px;
-moz-border-radius: 16px;
-webkit-border-radius: 16px;
border-radius: 16px;
border-width: none;
background: #ECF2F9;
cursor: pointer;
outline: none;
}
.btnP {
padding-right: 50px;
padding-left: 8px;
height: 24px;
font-size: 13px;
transition: all 0.3s ease 0s;
cursor: pointer;
white-space: nowrap;
position: relative;
text-decoration: none;
display: inline-block;
display: flex;
align-items: center;
margin-right: 16px;
text-align: center;
font-weight: bold;
font-size: 13px;
font-family: 'Noto Sans', sans-serif;
line-height: 6px;
letter-spacing: 0;
color: #51CC8B;
-ms-border-radius: 16px;
-o-border-radius: 16px;
-moz-border-radius: 16px;
-webkit-border-radius: 16px;
border-radius: 16px;
border-width: none;
background: #EDFAF3;
cursor: pointer;
outline: none;
}
.btnD {
padding-right: 50px;
padding-left: 8px;
height: 24px;
font-size: 13px;
transition: all 0.3s ease 0s;
cursor: pointer;
white-space: nowrap;
position: relative;
text-decoration: none;
display: inline-block;
display: flex;
align-items: center;
margin-right: 16px;
text-align: center;
font-weight: bold;
font-size: 13px;
font-family: 'Noto Sans', sans-serif;
line-height: 6px;
letter-spacing: 0;
color: #4981C2;
-ms-border-radius: 16px;
-o-border-radius: 16px;
-moz-border-radius: 16px;
-webkit-border-radius: 16px;
border-radius: 16px;
border-width: none;
background: #ECF2F9;
cursor: pointer;
outline: none;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.css" rel="stylesheet"/>
<div class="d-flex justify-content-md-center flex-nowrap myrow" style="margin-top: 160px;">
<a style="color: #51CC8B;" class="btnP">PRG
<span class="nav-link btn-glyphicon1">100</span>
</a>
<a style="color: #4981C2;" class="btnR">TRV
<span class="nav-link btn-glyphicon">50</span>
</a>
<a style="color: #4981C2;" class="btnD">DN
<span class="nav-link btn-glyphicon">21</span>
</a>
</div>

Text isn't anxiously aligned in span

The text-align (center) property isn't properly working for my text.
I have the following code:
<span class="info"> i <span id="uitleg_itje">Bla bla.
</span></span>
And the css for the info class is:
.info {
font-weight: bold;
text-align: center;
background-color: #C73C3C;
-moz-border-radius: 15px;
border-radius: 15px;
text-transform: lowercase;
letter-spacing: 4px;
color: #ffffff;
cursor: pointer;
font-size: 21px;
}
And the current result is:
This could be due to letter-spacing: 4px;
Instead of this and , you can try using padding instead.
.info {
font-weight: bold;
text-align: center;
background-color: #C73C3C;
-moz-border-radius: 15px;
border-radius: 15px;
text-transform: lowercase;
/*letter-spacing: 4px;*/
padding: 0 20px;
color: #ffffff;
cursor: pointer;
font-size: 21px;
}
<span class="info">i</span>
You can set div above span tag.Then your text will come in center.
.info {
font-weight: bold;
text-align: center;
background-color: #C73C3C;
-moz-border-radius: 15px;
border-radius: 15px;
text-transform: lowercase;
letter-spacing: 4px;
color: #ffffff;
cursor: pointer;
font-size: 21px;
}
div{
text-align:center;
}
<div>
<span class="info"> i <span id="uitleg_itje">Bla bla.
</span></span>
</div>

Change the look & feel of button

we have a button, its displaying like this :
we want to display like :
.saveall
{
text-transform: capitalize;
font-weight: bold;
float: left;
text-align: center;
color: #fff;
background: #3fbdf7;
font: 500 14px/1.35 Roboto Slab,Arial,Helvetica,sans-serif;
overflow: visible;
width: auto;
cursor: pointer;
vertical-align: middle;
display: inline-table;
padding: 9px;
position: relative;
margin-left: 6px;
margin-right: 6px;
}
<button class="saveall" title="Save all'" type="button" style="float: left;padding: 5px 5px 5px 0;" onclick="changeaction()" id="mass_update_butn">
<span><span>Invoice</span></span>
</button>
Please help me to find solution
thanks in advance
Seems simple enough.
Remove the inline styling and the border, then tweak the padding.
Those inner spand aren't really necessary unless you have a particular reason for having them.
.saveall {
text-transform: capitalize;
font-weight: bold;
text-align: center;
color: #fff;
background: #3fbdf7;
font: 500 14px/1.35 Roboto Slab, Arial, Helvetica, sans-serif;
cursor: pointer;
vertical-align: middle;
display: inline-block;
padding: 6px 24px;
position: relative;
border: none;
}
<button class="saveall" title="Save all'" type="button" onclick="changeaction()" id="mass_update_butn">
Invoice
</button>
Try this
button {
border: none;
background: #3FBDF7;
color: white;
font-size: 13px;
font-weight: bold;
padding: 5px 25px;
}
<button>Invoice</button>

aligning toggle button and making it look like one

So I am trying to align the toggle button I'm creating using CSS to be aligned with the 'paragraph description' as I'd like to call it but I can't seem to make it look the way I wanted it to look. I've not only provided a wireframe but a jsfiddle as well.
HTML code:
<p id="displayOption">Display Options</p>
<div id="onoffSwitch">
<ul id="btn" class="btn">
<li class="display-title" id="spoilers">
<span id="spoilerSwitch">Show/Hide Spoilers:</span>
<ul class="selector">
<li class="on">
<span class="onoffswitch-inner">
</li>
<li class="off">
<span class="onoffswitch-switch"></span></span>
</li>
</ul>
</li>
<li class="display-title" id="day-night">
<span id="day-nightSwitch">Day or Night Vision:</span>
<ul class="selector">
</ul>
</ul>
</div>
CSS code:
/***** options *****/
#displayOption {
text-align: center;
font-family: "Comic Sans MS", cursive, sans-serif;
border: .88px #efdaae;
border-top-right-radius: 10px;
border-top-left-radius: 10px;
/*-moz-border-radius: 10px;
-webkit-border-radius: 10px;*/
width: 258px;
background-color: #945e38;
padding: .1px;
margin: 0px;
font-variant: small-caps;
font-size: 1.5em;
color: #fdfdfa;
}
#displayOption-invert {
text-align: center;
font-family: "Comic Sans MS", cursive, sans-serif;
border: .88px #efdaae;
border-top-right-radius: 10px;
border-top-left-radius: 10px;
/*-moz-border-radius: 10px;
-webkit-border-radius: 10px;*/
width: 258px;
background-color: #efdaae;
padding: .1px;
margin: 0px;
font-variant: small-caps;
font-size: 1.5em;
color: #030303;
}
#onoffSwitch {
font-family: "Comic Sans MS", cursive, sans-serif;
border: 1px solid #945e38;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
padding: 7px 10px;
line-height: normal;
text-align: left;
padding-bottom: 18px;
color: #000000;
}
#onoffSwitch-invert {
font-family: "Comic Sans MS", cursive, sans-serif;
border: 1px solid #efdaae;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
padding: 7px 10px;
line-height: normal;
text-align: left;
padding-bottom: 18px;
color: #ffffff;
}
/*** unordered list ***/
#btn, #btn ul {
padding: 0px;
margin: 0px;
list-style-type: none; /*bullet removel*/
list-style: none; /*bullet removel*/
text-decoration: none; /*bullet removel*/
}
.display-title {
display: inline-block;
}
/*** text ***/
#spoilerSwitch, #daynightVision {
font-family: "Comic Sans MS", cursive, sans-serif;
line-height: normal;
color: #000000;
text-align: left;
margin-bottom: 10px;
}
#spoilerSwitch-invert, #daynightVision-invert {
font-family: "Comic Sans MS", cursive, sans-serif;
line-height: normal;
color: #FFFFFF;
text-align: left;
margin-bottom: 10px;
}
/*** toggle button ***/
.onoffswitch {
position: relative;
width: 50px;
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label, .onoffswitchInvert-label {
display: block;
overflow: hidden;
cursor: pointer;
border: 2px solid #999999;
border-radius: 0px;
}
.onoffswitch-inner, .offswitchInvert-inner {
display: block;
width: 200%;
margin-left: 100%;
transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
display: block;
float: left;
width: 50%;
height: 30px;
padding: 0;
line-height: 26px;
font-size: 14px;
color: white;
font-family: Trebuchet, Arial, sans-serif;
font-weight: bold;
box-sizing: border-box;
border: 2px solid transparent;
background-clip: padding-box;
}
.onoffswitch-inner:before {
content: "";
padding-left: 10px;
background-color: #2E8DEF;
color: #FFFFFF;
}
.onoffswitch-inner:after {
content: "";
padding-right: 10px;
background-color: #CCCCCC; color: #333333;
text-align: right;
}
.onoffswitch-switch {
display: block;
width: 25px;
margin: 0px;
background: #000000;
position: absolute;
top: 0;
bottom: 0;
right: 65px;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px;
}
Looking in Element browser in Google Chrome, you have this class messed up
.onoffswitch-inner:before, .onoffswitch-inner:after {
You should not be using "width: x%". You should change the % to some unit such as px.

CSS3 hover state background image size

So, when I hover over a button on my new site a background image of an arrow appears. Works great. But, in Chrome (haven't tested it yet on other browsers) the first appears as a big arrow, and a second later it changes to the right size.
This is my site:
http://stilld.nl/nieuw/
This is the code i'm using:
HTML:
<a class="btn1" href="contact/"><h4>
PLAN UW PROJECT
</h4></a>
CSS:
.item a {
text-decoration: none;
}
.item h4 {
position: absolute;
max-width: 200px;
width: 100%;
text-align: center;
font-family: 'Montserrat', sans-serif;
font-weight: 700;
line-height: 43px;
font-size: 16px;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 28px;
padding-right: 28px;
margin-top: 0px;
bottom: 180px;
left: 8.5%;
color: white;
border-radius: 6px;
letter-spacing: 0.5px;
text-transform: none;
border-style: solid;
border-width: 1.5px;
border-color: white;
-webkit-font-smoothing:antialiased;
background-position: 93% 50%;
background-repeat: no-repeat;
-o-transition:.5s;
-ms-transition:.5s;
-moz-transition:.5s;
-webkit-transition:.5s;
transition:.5s;
}
.item h4:hover {
position: absolute;
max-width: 200px;
text-align: center;
width: 100%;
text-align: center;
font-family: 'Montserrat', sans-serif;
font-weight: 700;
line-height: 43px;
font-size: 16px;
left: 8.5%;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 10px;
padding-right: 46px;
margin-top: 0px;
color: white;
background: url(../images/arrow_btn_banner.png) no-repeat;
background-size: 30px 30px;
background-position: 93% 50%;
border-radius: 6px;
letter-spacing: 0.5px;
text-transform: none;
border-style: solid;
border-width: 1.5px;
border-color: white;
-webkit-font-smoothing:antialiased;
}
I tried putten background-size above the background-image, but that doesn't work. I've tried changing the size of the image. But that isn't working either.
Maybe you should set background-image and background-size to 0 in h4
and only reset background-size on h4:hover, so bg image is already loaded.