Related
I'm trying to make a 'custom' progress bar with numbers at each end of the progress bar. Left hand number being the current value, and the right hand side being the max/target value. I've got it so that I'm showing the two numbers but I can't seem to position the right hand number correctly.
What I'm trying to achieve is...
and what I currently have is...
This is what I currently have code wise...
JSFiddle
.progress-outer {
width: 96%;
margin: 10px 2%;
padding: 3px;
text-align: center;
background-color: #f4f4f4;
border: 1px solid #dcdcdc;
color: #fff;
border-radius: 20px;
}
.progress-inner {
min-width: 15%;
white-space: nowrap;
overflow: hidden;
padding: 5px;
border-radius: 20px;
background-color: orange;
}
.progressBarCurrent {
color: black;
float: left;
}
.progressBarGoal {
color: black;
float: right;
}
<div class="progress-outer">
<div class="progress-inner" style="width:27%;">
<span class="progressBarCurrent">50g</span>
<span class="progressBarGoal">180g</span>
</div>
</div>
I've tried putting the the second span outside the the progress inner div but then moves the text outside the whole thing and I couldn't work out how to move it into the correct place.
Can anyone help?
I have an interesting solution using linear-gradients, its pretty close, try playing around with the margins and outline to get border right.
.progress-outer {
width: 96%;
display: flex;
height: 35px;
margin: 10px 2%;
text-align: center;
border: 1px solid #dcdcdc;
background-image: linear-gradient( 80deg, orange 37% , #f4f4f4 37% );
border-radius: 20px;
justify-content: center;
align-items: center;
}
.progressBarCurrent {
color: black;
text-align: left;
width: 50%;
position: relative;
margin: 0px;
margin-left: 20px;
}
.progressBarGoal {
color: black;
position: relative;
text-align: right;
width: 50%;
margin: 0px;
margin-right: 20px;
}
<div class="progress-outer">
<span class="progressBarCurrent">50g</span>
<span class="progressBarGoal">180g</span>
</div>
Instead of float:left you can use position:absolute
.progress-outer {
width: 96%;
margin: 10px 2%;
padding: 3px;
text-align: center;
background-color: #f4f4f4;
border: 1px solid #dcdcdc;
color: #fff;
border-radius: 20px;
position: relative;
}
.progress-inner {
min-width: 15%;
white-space: nowrap;
overflow: hidden;
padding: 5px;
border-radius: 20px;
background-color: orange;
}
.progressBarCurrent {
color: black;
float: left;
}
.progressBarGoal {
color: black;
position: absolute;
right: 5px;
}
<div class="progress-outer">
<div class="progress-inner" style="width:27%;">
<span class="progressBarCurrent">50g</span>
<span class="progressBarGoal">180g</span>
</div>
</div>
I am currently working on adding shadows to my custom icon and input. The current view is:
and the wanting output that I am looking for is:
I have been trying to add box-shadow, transparent background color, drop-shadow and this is the closest that I have achieved.
To mention, the arrow is an image:
body {
background-image: url('../images/bg2.jpg');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
height: 250px;
padding: 5px 15px 30px 15px;
width: 500px;
}
.text-center {
text-align: center;
}
*:focus {
outline: none;
}
.form-control {
align-items: center;
display: flex;
justify-content: center;
}
label {
display: block;
}
.help-text {
color: #FFFF;
font-size: 9px;
color: #999;
margin-right: 8px;
}
select,
input {
background: #582e79;
border-radius: 8px;
border: 1px #582e79;
color: #999;
filter: drop-shadow(1px 1px 1px #3c1f52);
margin-left: 25px;
margin-top: 135px;
padding: 5px 10px;
text-align: center;
width: 150px;
}
.mt10 {
margin-top: 20px;
}
.submit {
background-color: transparent;
background-image: url("../images/arrow.png");
background-position: center center;
background-repeat: no-repeat;
border: none;
height: 23px;
margin-left: 15px;
margin-top: 135px;
outline: none;
padding-bottom: 30px;
transition: 0.3s;
width: 23px;
}
<div class="text-center">
<div class="form-control mt10">
<input type="text" id="discord-id-input" name="discord-id-input" placeholder="Discord ID">
<button id="discord-id-button" type="submit" class="submit"></button>
</div>
<a class="help-text">ENTER DISCORD USER ID AND SUBMIT</a>
</div>
I wonder how can I add the shadow both to input and icon to be shadow like the wanting picture?
Simply use the box-shadow-property liek this:
box-shadow: 0 2px 0 Black;
which has following syntax
[horizontal offset] [vertical-offset] [blur] [color]
#discord-id-button,
#discord-id-input {
box-shadow: 0 2px 0 black;
}
/* original CSS */
body {
background-image: url('../images/bg2.jpg');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
height: 250px;
padding: 5px 15px 30px 15px;
width: 500px;
}
.text-center {
text-align: center;
}
*:focus {
outline: none;
}
.form-control {
align-items: center;
display: flex;
justify-content: center;
}
label {
display: block;
}
.help-text {
color: #FFFF;
font-size: 9px;
color: #999;
margin-right: 8px;
}
select,
input {
background: #582e79;
border-radius: 8px;
border: 1px #582e79;
color: #999;
filter: drop-shadow(1px 1px 1px #3c1f52);
margin-left: 25px;
margin-top: 135px;
padding: 5px 10px;
text-align: center;
width: 150px;
}
.mt10 {
margin-top: 20px;
}
.submit {
background-color: transparent;
background-image: url("../images/arrow.png");
background-position: center center;
background-repeat: no-repeat;
border: none;
height: 23px;
margin-left: 15px;
margin-top: 135px;
outline: none;
padding-bottom: 30px;
transition: 0.3s;
width: 23px;
}
.submit:hover {
background-image: url("../images/arrow-hover.png");
}
<div class="text-center">
<div class="form-control mt10">
<input type="text" id="discord-id-input" name="discord-id-input" placeholder="Discord ID">
<button id="discord-id-button" type="submit" class="submit"></button>
</div>
<a class="help-text">ENTER DISCORD USER ID AND SUBMIT</a>
</div>
I'm trying to implement the Pure-CSS-Multiline-Ellipsis solution (https://github.com/ericdrowell/Pure-CSS-Multiline-Ellipsis) which uses CSS only to add an ellipsis on text overflow. I've got it working when the text does indeed overflow, but if there is even a few characters on the last line of the content it adds the ellipsis even though no text is overflowing. This happens in FF (v67.0.2 (64-bit)), Chrome (v75.0.3770.80 (Official Build) (64-bit)) & Safari (v12.1.1):
(Text on the left is properly styled as the text is greater than the container, while the ellipsis shows on the example on the right even though the text ends at "world")
Here's my HTML (edited to show only the problematic div as otherwise the 3000 char limit is exceeded):
/*
* Pure CSS Multi-line Ellipsis
*/
.ellipsis-container {
overflow: hidden;
}
.ellipsis-container:before {
content: "";
float: left;
width: 1px;
height: 100%;
}
.ellipsis-wrapper {
float: right;
width: 100%;
margin-left: -1px;
}
.ellipsis-content {
margin: 0;
}
.ellipsis {
box-sizing: content-box;
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
float: right;
position: relative;
margin-right: 1px;
text-align: right;
}
body {
font-family: 'Roboto', sans-serif;
}
#page {
size: letter landscape;
}
#media print {
#page {
size: letter landscape;
}
}
.printout {
width: 100%;
height: 824px;
}
.top_margin_text {
text-align: center;
font-weight: 800;
color: red;
}
#first_div {
width: 312px;
height: 818px;
float: left;
padding: 3px;
border: 1px solid black;
background-image: url("https://wonderfest.com/contest/common/img/Copy_Watermark_copy_1_4_NEW copy.png");
background-position: 75% 45%;
background-repeat: no-repeat;
}
.first_div_bckgrnd_color {
background-color: rgba(192, 192, 192, 0.04);
}
.scissor_left {
width: 10px;
height: 818px;
float: left;
padding-top: 3px;
padding-bottom: 3px;
padding-left: 33px;
/*font-family: "Oxygen Mono", monospace;*/
}
.scissor_left img {
margin-left: -10px;
}
#second_div {
width: 312px;
height: 818px;
float: left;
margin-left: 30px;
padding: 3px;
border: 1px solid black;
background-image: url("https://wonderfest.com/contest/common/img/Copy_Watermark_copy_2_4_NEW copy.png");
background-position: 75% 45%;
background-repeat: no-repeat;
}
.second_div_bckgrnd_color {
background-color: rgba(255, 255, 204, 0.2);
}
.scissor_right {
width: 10px;
height: 818px;
float: left;
padding-top: 3px;
padding-bottom: 3px;
padding-left: 37px;
/*font-family: "Oxygen Mono", monospace;*/
}
.scissor_right img {
margin-left: -10px;
}
#third_div {
width: 312px;
height: 818px;
float: right;
padding: 3px;
border: 1px solid black;
background-image: url("https://wonderfest.com/contest/common/img/Copy_Watermark_copy_3_4_NEW copy.png");
background-position: 75% 45%;
background-repeat: no-repeat;
}
.third_div_bckgrnd_color {
background-color: rgba(255, 219, 235, 0.2);
}
.left_logo {
float: left;
width: 147px;
height: 50px;
display: inline;
}
.left_logo p {
clear: both;
width: 120px;
height: 16px;
color: white;
border-style: solid;
border-width: thin;
padding: 4px;
text-align: center;
margin-bottom: 10px;
margin-top: 2px;
margin-left: 4px;
font-size: small;
font-weight: 800;
background-color: black;
}
.second_logo {
float: left;
width: 165px;
height: 75px;
display: inline;
}
.second_logo span {
margin-left: 52px;
font-size: small;
}
.input-fields {
clear: both;
width: 310px;
margin-top: 3px;
margin-left: 3px;
font-size: small;
/* This is for the labels */
font-weight: bold;
}
/* .input-fields p{
border-radius: 3px;
word-wrap: break-word;
margin-top: 0px;
height: 64px;
width: 298px;
border: 1px solid black;
padding: 4px 4px 4px 4px;
font-size: 9pt;
font-weight: 300
line-height: 1.2em;
overflow: hidden;
}
*/
.ellipsis-container {
border: 1px solid black;
border-radius: 3px;
height: 68px;
width: 298px;
margin-top: 0px;
margin-left: 3px;
padding: 4px 4px 4px 4px;
}
.ellipsis-content {
/* it's critical to set a fixed font-size and line-height in order for
the ellipsis position to be predictable */
font-size: 9pt;
line-height: 1.2;
}
.ellipsis {
/* set width of ellipsis */
width: 60px;
margin-left: -60px;
/* set ellipsis position */
top: -13px;
left: 298px;
/* add a gradient background */
background: -webkit-gradient(linear, left top, right top, from(rgba(255, 255, 255, 0)), to(white), color-stop(50%, white));
background: -moz-linear-gradient(to right, rgba(255, 255, 255, 0), white 50%, white);
background: -o-linear-gradient(to right, rgba(255, 255, 255, 0), white 50%, white);
background: -ms-linear-gradient(to right, rgba(255, 255, 255, 0), white 50%, white);
background: linear-gradient(to right, rgba(255, 255, 255, 0), white 50%, white);
}
.ellipsis span {
display: inline-block;
font-size: 9pt;
height: 10px;
margin-right: 3px;
line-height: 1.2em;
}
.input-fields input {
width: 300px;
border: 1px solid black;
padding-left: 4px;
border-radius: 3px;
font-size: 9pt;
/*font-family: "Oxygen Mono", monospace;*/
font-weight: 400;
background-color: transparent !important;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.input-fields textArea {
width: 300px;
border: 1px solid black;
font-size: x-small;
/*font-family: "Oxygen Mono", monospace;*/
font-weight: 400;
}
.agreement {
width: 310px;
font-size: 5pt;
text-align: justify;
margin-left: 2px;
margin-bottom: 2px;
}
.accepted_agreement {
width: 310px;
margin-top: 0px;
font-size: 5pt;
text-align: center;
}
.fold_over {
width: 310px;
height: 20px;
margin-top: 4px;
margin-bottom: 20px;
font-size: x-small;
text-align: center;
font-weight: bold;
}
.Remarks {
width: 330px;
height: 295px;
margin-top: 2px;
margin-left: 3px;
/*font-size:small;
font-weight: bold;*/
}
.Remarks p {
border-radius: 3px;
word-wrap: break-word;
margin-top: 0px;
height: 265px;
width: 298px;
border: 1px solid black;
font-size: 9pt;
padding: 4px 4px 4px 4px;
/*font-family: "Oxygen Mono", monospace;*/
/*font-weight: 400;*/
white-space: normal;
}
.Remarks textarea {
width: 300px;
height: 227px;
border: 1px solid black;
font-size: 9pt;
/*font-family: "Oxygen Mono", monospace;
font-weight: 400;*/
}
.Paid_Watermark {
background: url("https://wonderfest.com/contest/common/img/WF_Paid_Watermark_sm copy 3.png") no-repeat bottom right;
}
.secure_model {
width: 310px;
height: 22px;
margin-top: 5px;
font-size: xx-small;
font-weight: bold;
text-align: center;
}
.secure_model input {
margin-top: 5px;
/*font-family: "Oxygen Mono", monospace;*/
font-size: xx-small;
border: 1px solid black;
background-color: LightGray !important;
text-align: center;
}
.barcode {
width: 310px;
height: 32px;
margin-top: 7px;
font-family: "Libre Barcode 39 Extended", cursive;
font-size: 24pt;
text-align: center;
}
.footer_text {
width: 310px;
height: 25px;
margin-top: 0px;
font-size: small;
}
.first_footer_text {
width: 75px;
height: 25px;
float: left;
text-align: center;
}
.first_footer_text input {
text-align: center;
border: 1px solid black;
/*font-family: "Oxygen Mono", monospace;*/
font-weight: 500;
}
.middle_footer_text {
width: 150px;
height: 45px;
text-align: center;
float: left;
font-weight: bold;
background-color: LightGray !important;
color: black !important;
}
.second_footer_text {
width: 75px;
height: 25px;
float: left;
text-align: center;
}
.second_footer_text input {
text-align: center;
border: 1px solid black;
/*font-family: "Oxygen Mono", monospace;*/
font-weight: 500;
}
<link href="https://fonts.googleapis.com/css?family=Libre+Barcode+39+Extended%7CRoboto" rel="stylesheet">
<div id="container">
<div class="printout">
<div id="third_div" class="entry_copy third_div_bckgrnd_color">
<div class="left_logo">
<img src="" width="138" height="29" alt="logo1">
<p>Entry Form 2019</p>
</div>
<div class="second_logo">
<img src="" width="168" height="62" alt="logo2">
</div>
<div class="input-fields">
<label>Name:</label><br><input type="text" name="name" value="TEST TESTXXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0" readonly>
</div>
<div class="input-fields">
<label>Phone:</label><br><input type="text" name="phone_num" value="5555551212XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0" readonly>
</div>
<div class="input-fields">
<label>Email:</label><br><input type="text" name="email" value="a#b.comXXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0" readonly>
</div>
<div class="agreement">
<p> I understand that due to the nature of the model contest, entries are sometimes handled and/or moved because of judging or space management.
<strong>WonderFest IS NOT</strong> responsible for loss or damage to entries into the model contest. I also grant WonderFest USA, Inc., permission to photograph my model(s) and use such photos in their marketing materials without limitation
or restriction.
</p>
</div>
<div class="accepted_agreement">
<span>Accepted agreement online: </span>
<span>15-Jun-19 at 03:08PM EDT</span>
</div>
<div class="fold_over">
<span>Fold Over</span><br><span>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span>
</div>
<div class="input-fields">
<label>Title or name of entry:</label><br>
</div>
<div class="ellipsis-container">
<div class="ellipsis-wrapper">
<p class="ellipsis-content">
Call me Ishmael. Some years ago – never mind how long precisely – having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.
</p>
</div>
<span class="ellipsis" href="#showMore">
…
</span>
</div>
<div id="Remark3" class="Remarks">
<label>Remarks:</label>
<p>fsdfdsfjdsajf fklsdfjsakf jadskfjadskfjdsafj</p>
<br>
</div>
<div class="input-fields">
<label>Category:</label><br><input type="text" value="Props" readonly>
</div>
<div class="secure_model">
<label>Is model secured to its base? </label><input type="text" size="3" name="secured_to_base" value="Yes" readonly><label style="margin-left:8px;">Oversized entry? </label><input type="text" size="3" name="isOversized" value="No" readonly>
</div>
<div class="barcode">
<span>*2019-1098*</span>
</div>
<div class="footer_text">
<div class="first_footer_text">
<span>Entry #</span>
<input type="text" name="entry_num" value="1098" style="width:50px;font-weight:700" readonly>
</div>
<div class="middle_footer_text">
<br><span style="font-size: 8pt">MODELER'S COPY</span>
</div>
<div class="second_footer_text">
<span>Table #</span>
<input type="text" name="table_num" value="" style="width:50px;" readonly>
</div>
</div>
</div>
</div>
</div>
The goal is to only show the ellipsis if the text overflows - what am I doing wrong?
My background is in desktop software so I'm just a HTML/CSS hobbyist.
The answer is that the contained text actually is taller than the container (by 4 invisible pixels), and so is acting as expected.
Essentially, line-height (and not just the text you see) and any other box padding will expand the contained element. Either increase the container's height a little, or lessen the content's line height a little.
I've modified your layout a little bit to show the issue. The second block is shorter, and no ellipsis. Console.log prints out their actual heights.
$(".ellipsis-container").each(function() {
console.log( $(this).height(), "vs", $(this).find('.ellipsis-content').height() , "pixels");
});
/*
* Pure CSS Multi-line Ellipsis
*/
.ellipsis-container {
overflow: hidden;
}
.ellipsis-container:before {
content: "";
float: left;
width: 1px;
height: 100%;
}
.ellipsis-wrapper {
float: right;
width: 100%;
margin-left: -1px;
}
.ellipsis-content {
margin: 0;
}
.ellipsis {
box-sizing: content-box;
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
float: right;
position: relative;
margin-right: 1px;
text-align: right;
}
body {
font-family: 'Roboto', sans-serif;
}
#page {
size: letter landscape;
}
#media print {
#page {
size: letter landscape;
}
}
.printout {
width: 100%;
height: 824px;
}
.top_margin_text {
text-align: center;
font-weight: 800;
color: red;
}
#first_div {
width: 312px;
height: 818px;
float: left;
padding: 3px;
border: 1px solid black;
background-image: url("https://wonderfest.com/contest/common/img/Copy_Watermark_copy_1_4_NEW copy.png");
background-position: 75% 45%;
background-repeat: no-repeat;
}
.first_div_bckgrnd_color {
background-color: rgba(192, 192, 192, 0.04);
}
.scissor_left {
width: 10px;
height: 818px;
float: left;
padding-top: 3px;
padding-bottom: 3px;
padding-left: 33px;
/*font-family: "Oxygen Mono", monospace;*/
}
.scissor_left img {
margin-left: -10px;
}
#second_div {
width: 312px;
height: 818px;
float: left;
margin-left: 30px;
padding: 3px;
border: 1px solid black;
background-image: url("https://wonderfest.com/contest/common/img/Copy_Watermark_copy_2_4_NEW copy.png");
background-position: 75% 45%;
background-repeat: no-repeat;
}
.second_div_bckgrnd_color {
background-color: rgba(255, 255, 204, 0.2);
}
.scissor_right {
width: 10px;
height: 818px;
float: left;
padding-top: 3px;
padding-bottom: 3px;
padding-left: 37px;
/*font-family: "Oxygen Mono", monospace;*/
}
.scissor_right img {
margin-left: -10px;
}
#third_div {
width: 312px;
height: 818px;
float: right;
padding: 3px;
border: 1px solid black;
background-image: url("https://wonderfest.com/contest/common/img/Copy_Watermark_copy_3_4_NEW copy.png");
background-position: 75% 45%;
background-repeat: no-repeat;
}
.third_div_bckgrnd_color {
background-color: rgba(255, 219, 235, 0.2);
}
.left_logo {
float: left;
width: 147px;
height: 50px;
display: inline;
}
.left_logo p {
clear: both;
width: 120px;
height: 16px;
color: white;
border-style: solid;
border-width: thin;
padding: 4px;
text-align: center;
margin-bottom: 10px;
margin-top: 2px;
margin-left: 4px;
font-size: small;
font-weight: 800;
background-color: black;
}
.second_logo {
float: left;
width: 165px;
height: 75px;
display: inline;
}
.second_logo span {
margin-left: 52px;
font-size: small;
}
.input-fields {
clear: both;
width: 310px;
margin-top: 3px;
margin-left: 3px;
font-size: small;
/* This is for the labels */
font-weight: bold;
}
/* .input-fields p{
border-radius: 3px;
word-wrap: break-word;
margin-top: 0px;
height: 64px;
width: 298px;
border: 1px solid black;
padding: 4px 4px 4px 4px;
font-size: 9pt;
font-weight: 300
line-height: 1.2em;
overflow: hidden;
}
*/
.ellipsis-container {
border: 1px solid black;
border-radius: 3px;
height: 68px;
width: 298px;
margin-top: 0px;
margin-left: 3px;
padding: 4px 4px 4px 4px;
}
.ellipsis-content {
/* it's critical to set a fixed font-size and line-height in order for
the ellipsis position to be predictable */
font-size: 9pt;
line-height: 1.2;
}
.ellipsis {
/* set width of ellipsis */
width: 60px;
margin-left: -60px;
/* set ellipsis position */
top: -13px;
left: 298px;
/* add a gradient background */
background: -webkit-gradient(linear, left top, right top, from(rgba(255, 255, 255, 0)), to(white), color-stop(50%, white));
background: -moz-linear-gradient(to right, rgba(255, 255, 255, 0), white 50%, white);
background: -o-linear-gradient(to right, rgba(255, 255, 255, 0), white 50%, white);
background: -ms-linear-gradient(to right, rgba(255, 255, 255, 0), white 50%, white);
background: linear-gradient(to right, rgba(255, 255, 255, 0), white 50%, white);
}
.ellipsis span {
display: inline-block;
font-size: 9pt;
height: 10px;
margin-right: 3px;
line-height: 1.2em;
}
.input-fields input {
width: 300px;
border: 1px solid black;
padding-left: 4px;
border-radius: 3px;
font-size: 9pt;
/*font-family: "Oxygen Mono", monospace;*/
font-weight: 400;
background-color: transparent !important;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.input-fields textArea {
width: 300px;
border: 1px solid black;
font-size: x-small;
/*font-family: "Oxygen Mono", monospace;*/
font-weight: 400;
}
.agreement {
width: 310px;
font-size: 5pt;
text-align: justify;
margin-left: 2px;
margin-bottom: 2px;
}
.accepted_agreement {
width: 310px;
margin-top: 0px;
font-size: 5pt;
text-align: center;
}
.fold_over {
width: 310px;
height: 20px;
margin-top: 4px;
margin-bottom: 20px;
font-size: x-small;
text-align: center;
font-weight: bold;
}
.Remarks {
width: 330px;
height: 295px;
margin-top: 2px;
margin-left: 3px;
/*font-size:small;
font-weight: bold;*/
}
.Remarks p {
border-radius: 3px;
word-wrap: break-word;
margin-top: 0px;
height: 265px;
width: 298px;
border: 1px solid black;
font-size: 9pt;
padding: 4px 4px 4px 4px;
/*font-family: "Oxygen Mono", monospace;*/
/*font-weight: 400;*/
white-space: normal;
}
.Remarks textarea {
width: 300px;
height: 227px;
border: 1px solid black;
font-size: 9pt;
/*font-family: "Oxygen Mono", monospace;
font-weight: 400;*/
}
.Paid_Watermark {
background: url("https://wonderfest.com/contest/common/img/WF_Paid_Watermark_sm copy 3.png") no-repeat bottom right;
}
.secure_model {
width: 310px;
height: 22px;
margin-top: 5px;
font-size: xx-small;
font-weight: bold;
text-align: center;
}
.secure_model input {
margin-top: 5px;
/*font-family: "Oxygen Mono", monospace;*/
font-size: xx-small;
border: 1px solid black;
background-color: LightGray !important;
text-align: center;
}
.barcode {
width: 310px;
height: 32px;
margin-top: 7px;
font-family: "Libre Barcode 39 Extended", cursive;
font-size: 24pt;
text-align: center;
}
.footer_text {
width: 310px;
height: 25px;
margin-top: 0px;
font-size: small;
}
.first_footer_text {
width: 75px;
height: 25px;
float: left;
text-align: center;
}
.first_footer_text input {
text-align: center;
border: 1px solid black;
/*font-family: "Oxygen Mono", monospace;*/
font-weight: 500;
}
.middle_footer_text {
width: 150px;
height: 45px;
text-align: center;
float: left;
font-weight: bold;
background-color: LightGray !important;
color: black !important;
}
.second_footer_text {
width: 75px;
height: 25px;
float: left;
text-align: center;
}
.second_footer_text input {
text-align: center;
border: 1px solid black;
/*font-family: "Oxygen Mono", monospace;*/
font-weight: 500;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Libre+Barcode+39+Extended%7CRoboto" rel="stylesheet">
<div id="container">
<div class="printout">
<div id="third_div" class="entry_copy third_div_bckgrnd_color">
<div class="left_logo">
<img src="" width="138" height="29" alt="logo1">
<p>Entry Form 2019</p>
</div>
<div class="second_logo">
<img src="" width="168" height="62" alt="logo2">
</div>
<div class="input-fields">
<label>Name:</label><br><input type="text" name="name" value="TEST TESTXXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0" readonly>
</div>
<div class="input-fields">
<label>Phone:</label><br><input type="text" name="phone_num" value="5555551212XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0" readonly>
</div>
<div class="input-fields">
<label>Email:</label><br><input type="text" name="email" value="a#b.comXXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0XXXXXXXXX0" readonly>
</div>
<div class="agreement">
<p> I understand that due to the nature of the model contest, entries are sometimes handled and/or moved because of judging or space management.
<strong>WonderFest IS NOT</strong> responsible for loss or damage to entries into the model contest. I also grant WonderFest USA, Inc., permission to photograph my model(s) and use such photos in their marketing materials without limitation
or restriction.
</p>
</div>
<div class="accepted_agreement">
<span>Accepted agreement online: </span>
<span>15-Jun-19 at 03:08PM EDT</span>
</div>
<div class="fold_over">
<span>Fold Over</span><br><span>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span>
</div>
<div class="input-fields">
<label>Title or name of entry:</label><br>
</div>
<div class="ellipsis-container">
<div class="ellipsis-wrapper">
<p class="ellipsis-content">
Call me Ishmael. Some years ago – never mind how long precisely – having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.
</p>
</div>
<span class="ellipsis" href="#showMore">
…
</span>
</div>
<div class="ellipsis-container">
<div class="ellipsis-wrapper">
<p class="ellipsis-content">
Call me Ishmael. Some years ago – never mind how long precisely – having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little [end].
</p>
</div>
<span class="ellipsis" href="#showMore">
…
</span>
</div>
<div class="input-fields">
<label>Category:</label><br><input type="text" value="Props" readonly>
</div>
<div class="secure_model">
<label>Is model secured to its base? </label><input type="text" size="3" name="secured_to_base" value="Yes" readonly><label style="margin-left:8px;">Oversized entry? </label><input type="text" size="3" name="isOversized" value="No" readonly>
</div>
<div class="barcode">
<span>*2019-1098*</span>
</div>
<div class="footer_text">
<div class="first_footer_text">
<span>Entry #</span>
<input type="text" name="entry_num" value="1098" style="width:50px;font-weight:700" readonly>
</div>
<div class="middle_footer_text">
<br><span style="font-size: 8pt">MODELER'S COPY</span>
</div>
<div class="second_footer_text">
<span>Table #</span>
<input type="text" name="table_num" value="" style="width:50px;" readonly>
</div>
</div>
</div>
</div>
</div>
What I want to achieve is something like this below
And what I am getting is something where there's too much of a gap between the image and the green border.
how do I make it look like the previous image above.
Here's the link to my codepen - codepen link
Here's the code:
.container {
text-align: center;
width: 80%;
}
.first {
background: rgb(0, 30, 58);
color: white;
}
.span1,
.span2 {
font-size: 36px;
font-weight: bold;
}
.span1 {
color: rgb(72, 174, 137);
}
[type="text"] {
border-radius: 25px;
padding-left: 5px;
}
[type="submit"] {
color: white;
background-color: rgb(72, 174, 137);
border-radius: 25px;
position: relative;
margin-left: -25px;
}
.use {
height: 85%;
margin: 0 auto;
}
.box {
border: 3px solid rgb(72, 174, 137);
width: 55%;
margin: 0 auto;
max-height: 210px;
}
.box .img-responsive {
margin-top: -20px;
}
.para {
text-align: left;
margin-right: 0;
padding-right: 0;
padding-top: 15px;
}
.para strong {
font-weight: 900;
font-size: 16px;
}
.second {
margin-bottom: 30px;
border: 1px solid green;
width: 10%;
}
.threebox {
width: 90%;
margin: 0 auto;
padding-left: 70px;
}
.col-lg-4 {
height: 40%;
}
.col-lg-4 > p {
background-color: white;
border: 2px solid white;
border-top-color: green;
width: 200px;
height: 160px;
box-shadow: 10px 10px 15px;
}
.positions {
margin-top: 60px;
position: relative;
margin-bottom: -50px;
z-index: 2;
}
.positions > h1 {
font-size: 30px;
font-weight: bold;
}
.spanf {
font-size: 18px;
font-weight: bold;
}
.features {
text-align: center;
padding-bottom: 40px;
width: 100%;
margin: 0 auto;
background-color: rgb(242, 243, 245);
height: 1500px;
z-index: 1;
padding-top: 120px;
margin-bottom: 0;
}
.features .row {
border: 2px solid red;
width: 65%;
margin: 0 auto;
}
.features .row p {
text-align: left;
padding-left: 20px;
}
.features button {
border-radius: 20px;
}
.features .row {
margin-top: 40px;
}
.features img {
width: 98%;
height: 98%;
}
.features .row .col-lg-6 {
padding-right: 15px;
padding-left: 2px;
}
.imgright {
position: relative;
border: 3px solid rgb(72, 174, 137);
top: 5%;
width: 40%;
padding-bottom: 0px;
padding-right: 2px;
padding-left: 0;
margin-left: 20px;
margin-top: 20px;
}
.img2 {
position: relative;
top: -25px;
left: -20px;
padding-bottom: 10px;
}
.imgleft {
position: relative;
border: 3px solid rgb(72, 174, 137);
width: 40%;
top: 5%;
margin-left: 10px;
margin-top: 20px;
}
.img3 {
position: relative;
top: -20px;
padding-bottom: 10px;
left: 40px;
}
.pillars {
background-color: rgb(72, 174, 137);
height: 350px;
top: 0;
}
This is the CSS after the changes and rest of your CSS will be there.
.features img {
/* width: 98%; */
/* height: 98%; */
left: 12px;
top: -12px;
box-shadow: -2px 2px 9px;
}
.features .row .col-lg-6 {
/* padding-right: 15px; */
/* padding-left: 2px; */
}
.img2 {
position: relative;
/* padding-bottom: 10px; */
}
.imgleft {
position: relative;
border: 3px solid rgb(72, 174, 137);
width: 40%;
top: 5%;
margin-left: 10px;
margin-top: 20px;
padding: 0;
}
.img3 {
position: relative;
left:30px;
/* top:-20px; */
/* padding-bottom: 10px; */
}
here u already defined .img2 and .img3 classes, your result was effecting by these classes just remove those classes then it works fine, check my snippet
.box .img-responsive {
margin-top: -20px;
} and remove margin-top from here
.container {
text-align: center;
width: 80%;
}
.first {
background: rgb(0, 30, 58);
color: white;
}
.span1,
.span2 {
font-size: 36px;
font-weight: bold;
}
.span1 {
color: rgb(72, 174, 137);
}
[type="text"] {
border-radius: 25px;
padding-left: 5px;
}
[type="submit"] {
color: white;
background-color: rgb(72, 174, 137);
border-radius: 25px;
position: relative;
margin-left: -25px;
}
.use {
height: 85%;
margin: 0 auto;
}
.box {
border: 3px solid rgb(72, 174, 137);
width: 55%;
margin: 0 auto;
max-height: 210px;
}
.box .img-responsive {
margin-top: -20px;
}
.para {
text-align: left;
margin-right: 0;
padding-right: 0;
padding-top: 15px;
}
.para strong {
font-weight: 900;
font-size: 16px;
}
.second {
margin-bottom: 30px;
border: 1px solid green;
width: 10%;
}
.threebox {
width: 90%;
margin: 0 auto;
padding-left: 70px;
}
.col-lg-4 {
height: 40%;
}
.col-lg-4 > p {
background-color: white;
border: 2px solid white;
border-top-color: green;
width: 200px;
height: 160px;
box-shadow: 10px 10px 15px;
}
.positions {
margin-top: 60px;
position: relative;
margin-bottom: -50px;
z-index: 2;
}
.positions > h1 {
font-size: 30px;
font-weight: bold;
}
.spanf {
font-size: 18px;
font-weight: bold;
}
.features {
text-align: center;
padding-bottom: 40px;
width: 100%;
margin: 0 auto;
background-color: rgb(242, 243, 245);
height: 1500px;
z-index: 1;
padding-top: 120px;
margin-bottom: 0;
}
.features .row {
border: 2px solid red;
width: 65%;
margin: 0 auto;
}
.features .row p {
text-align: left;
padding-left: 20px;
}
.features button {
border-radius: 20px;
}
.features .row {
margin-top: 40px;
}
.features img {
width: 98%;
height: 98%;
}
.features .row .col-lg-6 {
padding-right: 15px;
padding-left: 2px;
}
.imgright {
position: relative;
border: 3px solid rgb(72, 174, 137);
top: 5%;
width: 40%;
padding-bottom: 0px;
padding-right: 2px;
padding-left: 0;
margin-left: 20px;
margin-top: 20px;
}
.imgleft {
position: relative;
border: 3px solid rgb(72, 174, 137);
width: 40%;
top: 5%;
margin-left: 10px;
margin-top: 20px;
}
.pillars {
background-color: rgb(72, 174, 137);
height: 350px;
top: 0;
}
<div class="container">
<div class="first">
<p>CONVERSIFIC</p>
<p><span class="span1">The 1st</span><br>Business Intelligence Platform<br><span class="span2">for Shopify</span></p>
<p>We show you how to grow your revenue<br><span class="span3">-all you have to do is take action</span></p>
<form>
<input type="text" placeholder="enter your email" name="email">
<input type="submit" name="submit" value="Add me to Beta">
</form>
<p>Join our beta today,be the first to get access to Conversific</p>
</div><!--first div ends -->
<div class="use">
<h1>Why use Conversicif?</h1>
<hr class="firsth">
<div class="box row">
<div class="col-lg-6 images">
<img class="img-responsive " src="http://res.cloudinary.com/whizzy/image/upload/v1473309440/graph.jpg" alt="graph">
</div>
<div class="col-lg-6 para">
<p><strong>Conversific helps you make intelligent decisions to grow your business</strong><br>
There are plentfy of platforms that make it easy to capture data and analytics about your ecommerce site.But when it comes to understanding the data you've captured, it's not always clear what's important and where to make changes.</p>
</div>
</div><!--box div ends -->
<div class="positions">
<h1>How does Conversific work?</h1>
<p>Say goodbye to gathering reports and analyzing data and head straight to decision making </p>
<hr class="second">
<div class="threebox row">
<div class="col-lg-4"><p>Conversific is installed onto your ecommerce store with just one click from your shopify store</p></div>
<div class="col-lg-4"><p>After the installation you just need to install google analytics</p></div>
<div class="col-lg-4"><p>Immediately after you have signed in you see a comprehensive reports overview</p></div>
</div><!--threebox row ends -->
</div><!-- positions div ends-->
</div><!--use div ends -->
<div class="features">
<h1> Features you'll love</h1>
<p>These are the features you are going to love no matter what<br>
So, is this the end of the paragraph or what or are you gonna keep<br>
typing till your fingers bleed??</p>
<div class="row">
<div class="col-lg-6">
<p>ECOMMERCE FOCUS<br><span class="spanf">Decision Focused Dashboards To Supercharge Your Ecommerce Business</span><br>
There are plenty of platforms that make it easy to capture data and analytics about your ecommerce site. But when it comes to understanding the data you've captured. It's not always clear what's important and where to make changes.<br>
<button>Join Now</button></p>
</div>
<div class="col-lg-6 imgright">
<img class="img-responsive img2 " src="http://res.cloudinary.com/whizzy/image/upload/v1473309440/graph.jpg" alt="graph">
</div>
</div><!-- row ends -->
<div class="row">
<div class="col-lg-6 imgleft">
<img class="img-responsive img3" src="http://res.cloudinary.com/whizzy/image/upload/v1473309440/graph.jpg" alt="graph">
</div>
<div class="col-lg-6"><p>EASY TO UNDERSTAND<br><span class="spanf">Optimize Your Product & Category<br> Performance</span><br>
There are plenty of platforms that make it easy to capture data and analytics about your ecommerce site. But when it comes to understanding the data you've captured. It's not always clear what's important and where to make changes.<br>
<button>Join Now</button></p></div>
</div><!-- row ends -->
<div class="row">
<div class="col-lg-6"><p>INCREASE REVENUE<br><span class="spanf">Turbo Boost Your marketing and Find<br> Top Performing Marketing Channels</span><br>
See which marketing channels are the most effective for your business<br>and maximize your return on investment<br>
<button>Join Now</button></p></div>
<div class="col-lg-6 imgright">
<img class="img-responsive img2" src="http://res.cloudinary.com/whizzy/image/upload/v1473309440/graph.jpg" alt="graph">
</div>
</div><!-- row ends -->
<div class="row">
<div class="col-lg-6 imgleft">
<img class="img-responsive img3" src="http://res.cloudinary.com/whizzy/image/upload/v1473309440/graph.jpg" alt="graph">
</div>
<div class="col-lg-6"><p>ECOMMERCE FOCUS<br><span class="spanf">Decision Focused Dashboards To<br> Supercharge Your Ecommerce Business</span><br>
There are plenty of platforms that make it easy to capture data and analytics about your ecommerce site. But when it comes to understanding the data you've captured. It's not always clear what's important and where to make changes.<br>
<button>Join Now</button></p></div>
</div><!-- row ends -->
</div><!-- features div ends -->
<div class="pillars">
<h1>The 4 pillars of Conversific</h1>
<p>Stop wasting time on your decision making process, increase revenue and reduce costs </p>
<hr>
</div><!-- pillars div ends -->
<div class="team"></div>
<div class="end"></div>
</div><!-- container div ends -->
I would like to surround a number in a circle like in this image:
Is this possible and how is it achieved?
Here's a demo on JSFiddle and a snippet:
.numberCircle {
border-radius: 50%;
width: 36px;
height: 36px;
padding: 8px;
background: #fff;
border: 2px solid #666;
color: #666;
text-align: center;
font: 32px Arial, sans-serif;
}
<div class="numberCircle">30</div>
My answer is a good starting point, some of the other answers provide flexibility for different situations. If you care about IE8, look at the old version of my answer.
The problem with most of the other answers here is you need to tweak the size of the outer container so that it is the perfect size based on the font size and number of characters to be displayed. If you are mixing 1 digit numbers and 4 digit numbers, it won't work. If the ratio between the font size and the circle size isn't perfect, you'll either end up with an oval or a small number vertically aligned at the top of a large circle. This should work fine for any amount of text and any size circle. Just set the width and line-height to the same value:
.numberCircle {
width: 120px;
line-height: 120px;
border-radius: 50%;
text-align: center;
font-size: 32px;
border: 2px solid #666;
}
<div class="numberCircle">1</div>
<div class="numberCircle">100</div>
<div class="numberCircle">10000</div>
<div class="numberCircle">1000000</div>
If you need to make the content longer or shorter, all you need to do is adjust the width of the container for a better fit.
See it on JSFiddle.
For circle sizes varying based on the content this should work:
.numberCircle {
display: inline-block;
line-height: 0px;
border-radius: 50%;
border: 2px solid;
font-size: 32px;
}
.numberCircle span {
display: inline-block;
padding-top: 50%;
padding-bottom: 50%;
margin-left: 8px;
margin-right: 8px;
}
<span class="numberCircle"><span>30</span></span>
<span class="numberCircle"><span>1</span></span>
<span class="numberCircle"><span>5435</span></span>
<span class="numberCircle"><span>2</span></span>
<span class="numberCircle"><span>100</span></span>
It relies on the width of the content plus the margin-'s to determine the radius, then extends the height to match using the padding-'s. The margin-'s would need to be adjusted based on the font-size.
Update to remove inner element:
.numberCircle {
display: inline-block;
border-radius: 50%;
border: 2px solid;
font-size: 32px;
}
.numberCircle:before,
.numberCircle:after {
content: '\200B';
display: inline-block;
line-height: 0px;
padding-top: 50%;
padding-bottom: 50%;
}
.numberCircle:before {
padding-left: 8px;
}
.numberCircle:after {
padding-right: 8px;
}
<span class="numberCircle">30</span>
<span class="numberCircle">1</span>
<span class="numberCircle">5435</span>
<span class="numberCircle">2</span>
<span class="numberCircle">100</span>
Uses pseudo-elements to force the height. Need the zero width space for vertical alignment. Moved the line-height:0px from the outer to the pseudo so that it is at least visible when degrading for IE8.
If it's 20 and lower, you can just use the unicode characters ① ② ... ⑳
http://www.alanwood.net/unicode/enclosed_alphanumerics.html
the easiest way is using bootstrap and badge class
<span class="badge">1</span>
This version does not rely on hard-coded, fixed values but sizes relative to the font-size of the div.
http://jsfiddle.net/qod1vstv/
CSS:
.numberCircle {
font: 32px Arial, sans-serif;
width: 2em;
height: 2em;
box-sizing: initial;
background: #fff;
border: 0.1em solid #666;
color: #666;
text-align: center;
border-radius: 50%;
line-height: 2em;
box-sizing: content-box;
}
HTML:
<div class="numberCircle">30</div>
<div class="numberCircle" style="font-size: 60px">1</div>
<div class="numberCircle" style="font-size: 12px">2</div>
You can use the border-radius for this:
<html>
<head>
<style type="text/css">
.round
{
-moz-border-radius: 15px;
border-radius: 15px;
padding: 5px;
border: 1px solid #000;
}
</style>
</head>
<body>
<span class="round">30</span>
</body>
</html>
Play with the border radius and the padding values until you are satisfied with the result.
But this won't work in all browsers. I guess IE still does not support rounded corners.
I am surprised nobody used flex which is easier to understand, so I put my version of answer here:
To create a circle, make sure width equals height
To adapt to font-size of number in the circle, use em rather than px
To center the number in the circle, use flex with justify-content: center; align-items: center;
if the number grows (>1000 for example), increase the width and height at same time
Here is an example:
.circled-number {
color: #666;
border: 2px solid #666;
border-radius: 50%;
font-size: 1rem;
display: flex;
justify-content: center;
align-items: center;
width: 2em;
height: 2em;
}
.circled-number--big {
color: #666;
border: 2px solid #666;
border-radius: 50%;
font-size: 1rem;
display: flex;
justify-content: center;
align-items: center;
width: 4em;
height: 4em;
}
<div class="circled-number">
30
</div>
<div class="circled-number--big">
3000000
</div>
Late to the party, but here is a bootstrap-only solution that has worked for me. I'm using Bootstrap 4:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<body>
<div class="row mt-4">
<div class="col-md-12">
<span class="bg-dark text-white rounded-circle px-3 py-1 mx-2 h3">1</span>
<span class="bg-dark text-white rounded-circle px-3 py-1 mx-2 h3">2</span>
<span class="bg-dark text-white rounded-circle px-3 py-1 mx-2 h3">3</span>
</div>
</div>
</body>
You basically add bg-dark text-white rounded-circle px-3 py-1 mx-2 h3 classes to your <span> (or whatever) element and you're done.
Note that you might need to adjust margin and padding classes if your content has more than one digits.
My solution here - this easily allows for different sizes and colors and ties into a CMS for editorial control. For IE degrading to squares.
HTML:
<div class="circular-label label-outer label-size-large label-color-pink">
<div class="label-inner">
<span>Fashion & Beauty</span>
</div>
</div>
CSS:
.circular-label {
overflow: hidden;
z-index: 100;
vertical-align: middle;
font-size: 11px;
-webkit-box-shadow:0 3px 3px rgba(0, 0, 0, 0.2);
-moz-box-shadow:0 3px 3px rgba(0, 0, 0, 0.2);
box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.2);
}
.label-inner {
width: 85%;
height: 85%;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
border: 2px dotted white;
vertical-align: middle;
margin: auto;
top: 5%;
position: relative;
overflow: hidden;
}
.label-inner > span {
display: table;
text-align: center;
vertical-align: middle;
font-weight: bold;
text-transform: uppercase;
width: 100%;
position: absolute;
margin: auto;
margin-top: 38%;
font-family:'ProximaNovaLtSemibold';
font-size: 13px;
line-height: 1.0em;
}
.circular-label.label-size-large {
width: 110px;
height: 110px;
-moz-border-radius: 55px;
-webkit-border-radius: 55px;
border-radius: 55px;
margin-top:-55px;
}
.circular-label.label-size-med {
width: 76px;
height: 76px;
-moz-border-radius: 38px;
-webkit-border-radius: 38px;
border-radius: 38px;
margin-top:-38px;
}
.circular-label.label-size-med .label-inner > span {
margin-top: 33%;
}
.circular-label.label-size-small {
width: 66px;
height: 66px;
-moz-border-radius: 33px;
-webkit-border-radius: 33px;
border-radius: 33px;
margin-top:-33px;
}
It's not too difficult to see how to do this. The bigger question is whether it is possible to make the dimensions of the circle scale to content.
Currently I don't think it is possible. Anyone?
Here's a demo on JSFiddle and a snippet:
/* Creating a number within a circle using CSS */
.numberCircle {
font-family: "OpenSans-Semibold", Arial, "Helvetica Neue", Helvetica, sans-serif;
display: inline-block;
color: #fff;
text-align: center;
line-height: 0px;
border-radius: 50%;
font-size: 12px;
min-width: 38px;
min-height: 38px;
}
.numberCircle span {
display: inline-block;
padding-top: 50%;
padding-bottom: 50%;
margin-left: 1px;
margin-right: 1px;
}
/* Some Back Ground Colors */
.clrGreen {
background: #51a529;
}
.clrRose {
background: #e6568b;
}
.clrOrange {
background: #ec8234;
}
.clrBlueciel {
background: #21adfc;
}
.clrMauve {
background: #7b5d99;
}
<span class="numberCircle clrGreen"><span>8</span></span>
<span class="numberCircle clrRose"><span>80</span></span>
<span class="numberCircle clrOrange"><span>800</span></span>
<span class="numberCircle clrMauve"><span>8000</span></span>
.numberCircle {
border-radius: 50%;
width: 40px;
height: 40px;
display: block;
float: left;
border: 2px solid #000000;
color: #000000;
text-align: center;
margin-right: 5px;
}
<h3><span class="numberCircle">1</span> Regiones del Interior</h3>
Late to the party but here's the solution I went with https://codepen.io/jnbruno/pen/vNpPpW
Required no extra work.
Thanks John Noel Bruno
.btn-circle.btn-xl {
width: 70px;
height: 70px;
padding: 10px 16px;
border-radius: 35px;
font-size: 24px;
line-height: 1.33;
}
.btn-circle {
width: 30px;
height: 30px;
padding: 6px 0px;
border-radius: 15px;
text-align: center;
font-size: 12px;
line-height: 1.42857;
}
<div class="panel-body">
<h4>Normal Circle Buttons</h4>
<button type="button" class="btn btn-default btn-circle">
<i class="fa fa-check"></i>
</button>
<button type="button" class="btn btn-primary btn-circle">
<i class="fa fa-list"></i>
</button>
</div>
Do something like this in your css
div {
width: 10em; height: 10em;
-webkit-border-radius: 5em; -moz-border-radius: 5em;
}
p {
text-align: center; margin-top: 4.5em;
}
Use the paragraph tag to write the text. Hope that helps
Improving the first answer just get rid of the padding and add line-height and vertical-align:
.numberCircle {
border-radius: 50%;
width: 36px;
height: 36px;
line-height: 36px;
vertical-align:middle;
background: #fff;
border: 2px solid #666;
color: #666;
text-align: center;
font: 32px Arial, sans-serif;
}
The answer of thirtydot is right but is missing a little point. You need to add position: relative , if you want to have centered value in the circle and include also different range of number.
For example 123;
HTML:
<div class="numberCircle">30</div>
CSS:
.numberCircle {
border-radius: 50%;
behavior: url(PIE.htc); /* remove if you don't care about IE8 */
width: 36px;
height: 36px;
padding: 8px;
position: relative;
background: #fff;
border: 2px solid #666;
color: #666;
text-align: center;
font: 32px Arial, sans-serif;
}
but an easiest solution is to use Bootstrap
<span class="badge" style ="float:right">123</span>
Heres my way of doing it, using square method. upside is it works with different values, but you need 2 spans.
.circle {
display: inline-block;
border: 1px solid black;
border-radius: 50%;
position: relative;
padding: 5px;
}
.circle::after {
content: '';
display: block;
padding-bottom: 100%;
height: 0;
opacity: 0;
}
.num {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.width_holder {
display: block;
height: 0;
overflow: hidden;
}
<div class="circle">
<span class="width_holder">1</span>
<span class="num">1</span>
</div>
<div class="circle">
<span class="width_holder">11</span>
<span class="num">11</span>
</div>
<div class="circle">
<span class="width_holder">11111</span>
<span class="num">11111</span>
</div>
<div class="circle">
<span class="width_holder">11111111</span>
<span class="num">11111111</span>
</div>
You can use
span.red {
background: red;
border-radius: 0.8em;
-moz-border-radius: 0.8em;
-webkit-border-radius: 0.8em;
color: #ffffff;
display: inline-block;
font-weight: bold;
line-height: 1.6em;
margin-right: 15px;
text-align: center;
width: 1.6em;
}
span.grey {
background: #cccccc;
border-radius: 0.8em;
-moz-border-radius: 0.8em;
-webkit-border-radius: 0.8em;
color: #fff;
display: inline-block;
font-weight: bold;
line-height: 1.6em;
margin-right: 15px;
text-align: center;
width: 1.6em;
}
span.green {
background: #5EA226;
border-radius: 0.8em;
-moz-border-radius: 0.8em;
-webkit-border-radius: 0.8em;
color: #ffffff;
display: inline-block;
font-weight: bold;
line-height: 1.6em;
margin-right: 15px;
text-align: center;
width: 1.6em;
}
span.blue {
background: #5178D0;
border-radius: 0.8em;
-moz-border-radius: 0.8em;
-webkit-border-radius: 0.8em;
color: #ffffff;
display: inline-block;
font-weight: bold;
line-height: 1.6em;
margin-right: 15px;
text-align: center;
width: 1.6em;
}
span.pink {
background: #EF0BD8;
border-radius: 0.8em;
-moz-border-radius: 0.8em;
-webkit-border-radius: 0.8em;
color: #ffffff;
display: inline-block;
font-weight: bold;
line-height: 1.6em;
margin-right: 15px;
text-align: center;
width: 1.6em;
}
<h1><span class="grey">1</span>A grey circle with number inside</h1>
<h1><span class="red">2</span>A red circle with number inside</h1>
<h1><span class="blue">3</span>A blue circle with number inside</h1>
<h1><span class="green">4</span>A green circle with number inside</h1>
<h1><span class="pink">5</span>A pink circle with number inside</h1>
Thank to https://wpsites.net/web-design/colored-numbered-circles-using-pure-css-html/
Something like this could work (for numbers 0 to 99):
.circle {
border: 0.1em solid grey;
border-radius: 100%;
height: 2em;
width: 2em;
text-align: center;
}
.circle p {
margin-top: 0.10em;
font-size: 1.5em;
font-weight: bold;
font-family: sans-serif;
color: grey;
}
<body>
<div class="circle">
<p>30</p>
</div>
</body>
You work like with a standard block, that is a square
This is feature of CSS 3 and it is not very well suporrted, you can count on firefox and safari for sure.
.circle {
width: 10em;
height: 10em;
-webkit-border-radius: 5em;
-moz-border-radius: 5em;
border: 1px solid black;
}
<div class="circle"><span>1234</span></div>