Align 3 columns, middle column HR adjustable - html

i have this section:
What I'm trying to achieve, is to have the left span, with a padding on the right, then on the middle the HR, and on the right the span with the price, but I want to have the price align to the right, and make the HR adjustable, so it always ends on the price and starts after the first span. I'm not being able to achieve this, no matter what I try.
Here is the code:
<div class="ementaspan"><span class="span1"><h5 class="font-150690 h5 font-weight-600 text-color-118181-color" style="
display: inline-block;
"><span>Creme de Baunilha</span></h5></span> <span><hr class="dotted border-accent-color separator-no-padding" style="width: 90%;border-top-width: 4px;"></span><span class="span3"><h5 class="font-150690 h5 font-weight-300"><span>1,60€</span></h5></span></div>
Creme de Nata 1,60€
And the CSS:
.ementaspan span h5, .ementaspan hr {
display: inline-block !important;
}
.ementaspan {
text-align: left !important;
}
.ementaspan .span1 {
width: 25% !important;
}
.ementaspan .span1 h5 {
padding-right: 25px;
}
.ementaspan hr {
width: 50% !important;
}
.ementaspan .span3 {
width: 25% !important;
}
.ementaspan .span3 h5 {
padding-left: 25px;
}

the easiest way is to do it with flex
.maindiv {
display: flex;
width: 100%;
justify-content: space-between;
align-items: flex-end;
}
.maindiv .div1 {
padding-right: 20px;
}
.maindiv .div2 {
flex: 1 1 auto;
}
.maindiv .div2 hr {
height: 0;
background: none;
color: transparent;
border-bottom: 3px dotted #f00;
border-top: none !important;
margin: 0 0 4px !important;
}
.maindiv .div3 {
padding-left: 20px;
color: #f00;
}
<div class="maindiv">
<div class="div1">Creme de Baunilha</div>
<div class="div2"><hr></div>
<div class="div3">1,60€</div>
</div>
<div class="maindiv">
<div class="div1">Creme de Nata</div>
<div class="div2"><hr></div>
<div class="div3">11,60€</div>
</div>
<div class="maindiv">
<div class="div1">Baunilha e Noz</div>
<div class="div2"><hr></div>
<div class="div3">1,60€</div>
</div>
<div class="maindiv">
<div class="div1">Baunilha e Cookies</div>
<div class="div2"><hr></div>
<div class="div3">121,60€</div>
</div>

Playing a little with your code,
I ended up with this:
.ementaspan {
display: flex;
width: 100%;
text-align: left !important;
}
.ementaspan span h5 {
display: inline-block !important;
}
.ementaspan .span2 {
flex: auto;
padding: 20px; /* Instead of padding on span1 and span3 */
}
.ementaspan hr {
background: none;
color: transparent;
border: 0; /* Resets hr style */
border-bottom: 4px dotted #f00;
}
.ementaspan .span3 {
width: 25% !important;
color: #f00;
}
<div class="ementaspan">
<span class="span1">
<h5 class="font-150690 h5 font-weight-600 text-color-118181-color" style="
display: inline-block;
"><span>Creme de Baunilha</span></h5>
</span>
<span class="span2">
<hr class="dotted border-accent-color separator-no-padding">
</span>
<span class="span3">
<h5 class="font-150690 h5 font-weight-300"><span>1,60€</span></h5>
</span>
</div>
<div class="ementaspan">
<span class="span1">
<h5 class="font-150690 h5 font-weight-600 text-color-118181-color" style="
display: inline-block;
"><span>Creme de Nata</span></h5>
</span>
<span class="span2">
<hr class="dotted border-accent-color separator-no-padding">
</span>
<span class="span3">
<h5 class="font-150690 h5 font-weight-300"><span>2,60€</span></h5>
</span>
</div>
<div class="ementaspan">
<span class="span1">
<h5 class="font-150690 h5 font-weight-600 text-color-118181-color" style="
display: inline-block;
"><span>Baunilha e Noz</span></h5>
</span>
<span class="span2">
<hr class="dotted border-accent-color separator-no-padding">
</span>
<span class="span3">
<h5 class="font-150690 h5 font-weight-300"><span>10,60€</span></h5>
</span>
</div>
Note that I kept all your classes and your html structure.
The only HTML modification is the span2 class,
then you'll only need to copy/paste the CSS to try it!
I hope it helps.

Related

Positioning divs (left-right) with CSS [duplicate]

This question already has answers here:
CSS Float: Floating an image to the left of the text
(7 answers)
Align image to left of text on same line - Twitter Bootstrap3
(6 answers)
Wrap text around an image on bootstrap 3
(6 answers)
Closed 3 years ago.
I'm designing people cards and I need to positionate the image on the left side and the text on the right side but I'm having issues doing it.
.row {
display: flex;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
}
.col-lg-3 {
position: relative;
width: 100%;
padding-right: 15px;
padding-left: 15px;
}
.media {
margin: 20px 0;
padding: 10px;
vertical-align: middle;
display: inline-block;
width: 100%;
overflow-wrap: break-word;
word-wrap: break-word;
}
<div class="row">
<div class="col-lg-3">
<div class="media">
<div id="left_div">
<img src="/web/image/hr.employee/7/image">
</div>
<div id="right_div">
<span class="label label-default">Marc Demo
<hr style="margin: 0em; border-width: 2px;">
</span>
<span class="label label-default"> HIPOACUSICOS
<hr style="margin: 0em; border-width: 2px;">
</span>
<span class="label label-default">mark.brown23#example.com
<hr style="margin: 0em; border-width: 2px; display: none;">
</span>
</div>
</div>
</div>
I'm trying to use position, width and another properties on "left_div" and "right_div" but I'm not able to format it.
Any suggestion?
Edit: Using display: flex and align-items: center this is the result of it:
Maybe the problem are the inherited styles of other parent divs?
Thanks for reading!
Use display: flex on .media, then use display: block on span elements
You could also avoid to use a presentational tag (<hr>) and use a border-bottom.
Note that if the horizontal space is not enough due to a narrow container you need to wrap the content as in my second example.
.media {
display: flex;
flex-flow: row wrap;
align-items: center; /* optional */
margin: 20px 0;
padding: 10px;
width: 100%;
background: #e8e8e8; }
.media > div {
padding: 10px; }
.media img {
vertical-align: middle;
max-width: 100%;
width: 200px; }
#left_div {
text-align: center;
flex: 1 0 25%; }
#right_div {
flex: 3 0 60%; }
.media span {
display: block;
padding: 5px 0;
word-break: break-all;
word-break: break-word;
border-bottom: 1px #ccc solid; }
<div class="media">
<div id="left_div">
<img src="https://i.stack.imgur.com/UJ3pb.jpg">
</div>
<div id="right_div">
<span class="label label-default">Marc Demo</span>
<span class="label label-default"> HIPOACUSICOS </span>
<span class="label label-default">mark.brown23#example.com </span>
</div>
</div>
<!-- example with narrow parent -->
<div style="width: 200px;">
<div class="media">
<div id="left_div">
<img src="https://i.stack.imgur.com/UJ3pb.jpg">
</div>
<div id="right_div">
<span class="label label-default">Marc Demo</span>
<span class="label label-default"> HIPOACUSICOS </span>
<span class="label label-default">mark.brown23#example.com </span>
</div>
</div>
</div>
Easiest way to do this is to use flexbox.
Make the parent, .media, a flex container, and align-items: center replacing vertical-align: middle
EDIT
I've edited my answer to show 2 "profile cards" side by side. In doing so, I've changed left_div and right_div into classes instead of id, and gave left_div a 40% width.
.row {
display: flex;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
}
.col-lg-3 {
position: relative;
width: 100%;
padding-right: 15px;
padding-left: 15px;
display: flex;
}
.media {
margin: 20px 0;
padding: 10px;
display: flex;
align-items: center;
width: 100%;
overflow-wrap: break-word;
word-wrap: break-word;
background-color: #ddd;
margin-right: 15px;
}
.left_div {
width: 40%;
margin-right: 15px;
}
.right_div {
width: 60%;
}
img {
width: 100%;
height: auto;
}
<div class="row">
<div class="col-lg-3">
<div class="media">
<div class="left_div">
<img src="https://i.stack.imgur.com/UJ3pb.jpg">
</div>
<div class="right_div">
<span class="label label-default">Marc Demo
<hr style="margin: 0em; border-width: 2px;">
</span>
<span class="label label-default"> HIPOACUSICOS
<hr style="margin: 0em; border-width: 2px;">
</span>
<span class="label label-default">mark.brown23#example.com
<hr style="margin: 0em; border-width: 2px; display: none;">
</span>
</div>
</div>
<div class="media">
<div class="left_div">
<img src="https://i.stack.imgur.com/UJ3pb.jpg">
</div>
<div class="right_div">
<span class="label label-default">Some one
<hr style="margin: 0em; border-width: 2px;">
</span>
<span class="label label-default"> Barbar
<hr style="margin: 0em; border-width: 2px;">
</span>
<span class="label label-default">fubar#example.com
<hr style="margin: 0em; border-width: 2px; display: none;">
</span>
</div>
</div>
</div>
</div>
You could use flexbox for doing this stuff. Also, I would recommend using classes instead if id's because of css specificity
.row {
display: flex;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
}
.col-lg-3 {
position: relative;
width: 100%;
padding-right: 15px;
padding-left: 15px;
}
.media {
margin: 20px 0;
padding: 10px;
display: flex;
}
.media > div{
display: flex;
justify-content: center;
flex-direction: column;
}
.media .right_div{
padding: 10px;
}
<div class="row">
<div class="col-lg-3">
<div class="media">
<div class="left_div">
<img src="https://placehold.it/200x200">
</div>
<div class="right_div">
<span class="label label-default">Marc Demo
<hr style="margin: 0em; border-width: 2px;">
</span>
<span class="label label-default"> HIPOACUSICOS
<hr style="margin: 0em; border-width: 2px;">
</span>
<span class="label label-default">mark.brown23#example.com
<hr style="margin: 0em; border-width: 2px; display: none;">
</span>
</div>
</div>
</div>
You could try a few things here - difficult to get the exact styles right without the design, but you could simply add "display: flex;" to the .media rules.
.row {
display: flex;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
}
.col-lg-3 {
position: relative;
width: 100%;
padding-right: 15px;
padding-left: 15px;
}
.media {
margin: 20px 0;
padding: 10px;
vertical-align: middle;
display: inline-block;
width: 100%;
overflow-wrap: break-word;
word-wrap: break-word;
display: flex;
flex-flow: row nowrap;
}
/* You can customise the flex items here to adjust the spacing/styles etc. */
.media .left_div {
flex: 1;
}
.media .right_div {
flex: 1;
}
<div class="row">
<div class="col-lg-3">
<div class="media">
<div class="left_div">
<img src="/web/image/hr.employee/7/image">
</div>
<div class="right_div">
<span class="label label-default">Marc Demo
<hr style="margin: 0em; border-width: 2px;">
</span>
<span class="label label-default"> HIPOACUSICOS
<hr style="margin: 0em; border-width: 2px;">
</span>
<span class="label label-default">mark.brown23#example.com
<hr style="margin: 0em; border-width: 2px; display: none;">
</span>
</div>
</div>
</div>
I've also changed your HTML to use classes instead of IDs for left_div and right_div, as really an ID should not be used more than once on a page.
You can use display: flex to .media like this:
.media {
display: flex;
align-items: center;
margin: 20px 0;
padding: 10px;
vertical-align: middle;
display: inline-block;
width: 100%;
overflow-wrap: break-word;
word-wrap: break-word;
}
Also as I can see data getting out of container. You can use overflow-x: auto; or changing col-lg-3 to some larger classes
Add flex to media class as below
.media {
display: flex;
}

Make div width same as its content width [duplicate]

This question already has answers here:
How can I make a div not larger than its contents?
(43 answers)
Closed 5 years ago.
I have attached a fiddle link to this question. I need the red dot to be closer to the text. For the first & last item, it works well..but if any item is multi line..it has extra whitespace at the right..i want the dot to be closer to the text for the second item also.I tried flex:0 but it makes the whole text area smaller.Please help!
<div class="container">
<div class="item">
<span class="icon">1</span>
<div class="text">News Section</div>
<span class="red"></span>
</div>
<div class="item">
<span class="icon">2</span>
<div class="text">Sample123 Organizational announcement</div>
<span class="red"></span>
</div>
<div class="item">
<span class="icon">3</span>
<div class="text">Sample Text</div>
<span class="red"></span>
</div>
</div>
.container {
width:300px;
padding: .5em 1em;
}
.item {
display: flex;
}
.icon {
width: 18px;
float: left;
}
.text {
display: inline-block;
background: yellow;
}
.red {
margin: 0 0 0 0.5rem !important;
background: #FF0000;
padding: 0 !important;
width: .5rem;
height: .5rem;
border-radius: 50%;
}
Link to fiddle
Use white-space: nowrap; inside .text class it's working.
.container {
width:300px;
padding: .5em 1em;
}
.item {
display: inline-flex;
}
.icon {
width: 18px;
float: left;
}
.text {
display: inline-block;
background: yellow;
white-space: nowrap;
}
.red {
margin: 0 0 0 0.5rem !important;
background: #FF0000;
padding: 0 !important;
width: .5rem;
height: .5rem;
border-radius: 50%;
}
<div class="container">
<div class="item">
<span class="icon">1</span>
<div class="text">News Section</div>
<span class="red"></span>
</div>
<div class="item">
<span class="icon">2</span>
<div class="text">Sample123 Organizational announcement</div>
<span class="red"></span>
</div>
<div class="item">
<span class="icon">3</span>
<div class="text">Sample Text</div>
<span class="red"></span>
</div>
</div>

Aligning elements according to image

could someone help me with an example how to accomplish following layout? Is tables the best for this?
https://gyazo.com/80a2f66d280c480c1e6e70637959b271
I do not want to hardcode the width of the elements because I need it to be responsive aswell, thats why I am having a hard time..
So basicly I need it centered but not text-align centered. Appreciate all the help I could get.
Don't use tables, this makes it hard to optimize the website for mobile devices. Here's what I would do:
body {
font-family: Arial, sans-serif;
color: #444444;
}
.info {
border: 1px solid #bbbbbb;
border-width: 1px 0;
padding: 10px;
}
.row {
line-height: 30px;
padding: 10px;
}
.label {
display: inline-block;
width: 30%; /* You may want to adjust this property */
margin: 0 10px;
text-align: right;
font-size: 95%;
color: #888888;
}
button {
border: none;
background-color: #43CEAD;
border-radius: 3px;
padding: 4px 10px;
color: white;
font-size: 90%;
}
.right {
float: right;
}
<div class="info">
<div class="row">
<span class="label">Name:</span>
John Doe
<button class="right">Edit</button>
</div>
<div class="row">
<span class="label">Password:</span>
********
<button class="right">Edit</button>
</div>
<div class="row">
<span class="label">Animus Heart ID:</span>
B0 23459332
<button class="right">Edit</button>
</div>
<div class="row">
<span class="label">E-mail:</span>
john#doe.com
<button class="right">Edit</button>
</div>
</div>
Why tables? You can set div width in percent, isn't it?
.col--first {
width: 40%;
float: left;
text-align: right;
}
.col--second {
margin-left: 1%;
width: 59%;
float: left;
}
.col--second:after {
content: '';
display: table;
clear: both;
}
.right {
float: right;
}
<div>
<div class="col--first">Name:</div>
<div class="col--second">John
<button class="right">Edit</button>
</div>
<div class="col--first">Password:</div>
<div class="col--second">******
<button class="right">Edit</button>
</div>
</div>
Have a look at responsive tables:
.table {
display: table;
}
.table > .row {
display: table-row;
}
.table > .row > .cell {
display: table-cell;
}
<div class="table">
<div class="row">
<div class="cell">
First
</div>
<div class="cell">
Second
</div>
<div class="cell">
Third
</div>
</div>
</div>
#img {
width: 100%;
margin: 0 auto;
}
Width can be changed to reflect the desired size of the image, but this will center the image based on the parent element's size by dividing the two margins equally on the left and right.

How to flip the text inside the div tag?

.hot-deals-row{
margin-top: 30px;
background: #eaeaea;
}
.hot-deals-box{
border: 1px solid #eaeaea;
}
.hot-deals-box .hot-deals-tab {
display: table;
width: 100%;
}
.hot-deals-box .hot-deals-tab .hot-deals-title{
width: 45px;
display: table-cell;
text-transform: uppercase;
font-size: 24px;
text-align: center;
background: #0088cc;
color: #fff;
padding-top: 2px;
}
.hot-deals-box .hot-deals-tab .hot-deals-title>span{
width: 100%;
float: left;
text-align: center;
}
.hot-deals-box .hot-deals-tab .hot-deals-title>span.yellow{
color: #ffcc00;
}
.hot-deals-box .hot-deals-tab .hot-deals-tab-box{
display: table-cell;
padding:25px;
}
.hot-deals-box .hot-deals-tab .hot-deals-tab-box .nav-tab li{
line-height: 40px;
border-bottom: 1px solid #eaeaea;
text-transform: uppercase;
padding-left: 15px;
}
.hot-deals-box .hot-deals-tab .hot-deals-tab-box .nav-tab li.active>a{
color: #0099cc;
}
.hot-deals-box .hot-deals-tab .box-count-down{
margin-top: 20px;
float: left;
padding-left: 4px;
}
.hot-deals-box .hot-deals-tab .box-count-down .box-count{
width: 67px;
height:67px;
border:1px solid #eaeaea;
float: left;
border-radius: 90%;
text-align: center;
padding: 10px;
position: relative;
color: #fff;
margin-left: -4px;
background: #fff;
}
.hot-deals-box .hot-deals-tab .box-count-down .dot{
display: none;
}
.hot-deals-box .hot-deals-tab .box-count-down .box-count:before{
width: 100%;
height: 100%;
background: #0088cc;
float: left;
content: '';
border-radius: 90%;
}
.hot-deals-box .hot-deals-tab .box-count-down .box-count:after{
content: '';
width: 23px;
height: 1px;
background: #fff;
position: absolute;
top: 34px;
left: 20px;
}
.hot-deals-box .hot-deals-tab .box-count-down .number{
position: absolute;
width: 100%;
left: 0;
top: 15px;
}
.hot-deals-box .hot-deals-tab .box-count-down .text{
position: absolute;
width: 100%;
left: 0;
bottom: 16px;
font-size: 10px;
}
.hot-deals-box .hot-deals-tab-content-col{
padding-left: 0;
}
.hot-deals-box .hot-deals-tab-content{
padding: 30px 30px 0 0;
}
.hot-deals-box .product-list .left-block{
border: 1px solid #eaeaea;
padding: 0;
}
.hot-deals-box .product-list .right-block {
text-align:center;
font-family: "Comic Sans MS", cursive;
font-size: large;
}
<div class="hot-deals-row">
<div class="container">
<div class="hot-deals-box">
<div class="row">
<div class="col-sm-2 col-md-2 col-lg-1">
<div class="hot-deals-tab">
<div class="hot-deals-title vertical-text">
<span>D</span>
<span>E</span>
<span>A</span>
<span>L</span>
<span class="yellow">O</span>
<span class="yellow">F</span>
<span>T</span>
<span>H</span>
<span>E</span>
<span class="yellow">d</span>
<span class="yellow">a</span>
<span class="yellow">y</span>
</div>
</div>
<div class="col-sm-10 col-md-10 col-lg-10 hot-deals-tab-content-col">
<div class="hot-deals-tab-content tab-container">
<div id="hot-deal-1" class="tab-panel active">
<ul class="product-list owl-carousel nav-center" data-dots="false" data-loop="true" data-nav = "true" data-margin = "29" data-autoplayTimeout="1000" data-autoplayHoverPause = "true" data-responsive='{"0":{"items":1},"600":{"items":3},"1000":{"items":4}}'>
<li>
<div class="left-block">
<img class="img-responsive" alt="product" src="assets/data/option4/p8.jpg" />
</div>
<div class="price-percent-reduction2">
20% OFF
</div>
<div class="right-block">
<h5 class="product-name">Android Smartphone </h5>
<div class="content_price">
<span class="price product-price">$48,95</span>
<span class="price old-price">$62,00</span>
</div>
</div>
</li>
<li>
<div class="left-block">
<img class="img-responsive" alt="product" src="assets/data/option4/p12.jpg" />
</div>
<div class="price-percent-reduction2">
30% OFF
</div>
<div class="right-block">
<h5 class="product-name">Micromax X1800</h5>
<div class="content_price">
<span class="price product-price">$68,95</span>
<span class="price old-price">$82,00</span>
</div>
</div>
</li>
<li>
<div class="left-block">
<img class="img-responsive" alt="product" src="assets/data/option4/p11.jpg" />
</div>
<div class="price-percent-reduction2">
40% OFF
</div>
<div class="right-block">
<h5 class="product-name">Desire 620G 5-Inch Dual SIM Android </h5>
<div class="content_price">
<span class="price product-price">$58,95</span>
<span class="price old-price">$72,00</span>
</div>
</div>
</li>
<li>
<div class="left-block">
<img class="img-responsive" alt="product" src="assets/data/option4/p12.jpg" />
</div>
<div class="price-percent-reduction2">
10% OFF
</div>
<div class="right-block">
<h5 class="product-name">Canvas Juice 2 AQ5001 </h5>
<div class="content_price">
<span class="price product-price">$84,95</span>
<span class="price old-price">$95,00</span>
</div>
</div>
</li>
</ul>
</div>
image1
my desktop view is like shown in the image1.
image2
when i resize my screen the output i get is shown in the image2.
Now i want to convert these image2 into the horizontal view when my screen size is 767px.
You need a media query something like this:
#media screen and (max-width: 767px) {
.hot-deals-box .hot-deals-tab .hot-deals-title > span {
width: auto;
display: inline-block;
}
}
JSfiddle Demo
.hot-deals-row {
margin-top: 30px;
background: #eaeaea;
}
.hot-deals-box {
border: 1px solid #eaeaea;
}
.hot-deals-box .hot-deals-tab {
display: table;
width: 100%;
}
.hot-deals-box .hot-deals-tab .hot-deals-title {
//width: 45px;
display: table-cell;
text-transform: uppercase;
font-size: 24px;
text-align: center;
background: #0088cc;
color: #fff;
padding-top: 2px;
}
.hot-deals-box .hot-deals-tab .hot-deals-title > span {
width: 100%;
float: left;
text-align: center;
}
.hot-deals-box .hot-deals-tab .hot-deals-title>span.yellow {
color: #ffcc00;
}
.hot-deals-box .hot-deals-tab .hot-deals-tab-box {
display: table-cell;
padding: 25px;
}
#media screen and (max-width: 767px) {
.hot-deals-box .hot-deals-tab .hot-deals-title > span {
width: auto;
display: inline-block;
}
}
<div class="hot-deals-row">
<div class="container">
<div class="hot-deals-box">
<div class="row">
<div class="col-sm-2 col-md-2 col-lg-1">
<div class="hot-deals-tab">
<div class="hot-deals-title vertical-text"> <span>D</span>
<span>E</span>
<span>A</span>
<span>L</span>
<span class="yellow">O</span>
<span class="yellow">F</span>
<span>T</span>
<span>H</span>
<span>E</span>
<span class="yellow">d</span>
<span class="yellow">a</span>
<span class="yellow">y</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

Center according to element that has sibling with a larger width

I have a group of stats styled as shown below, but if I want to center the group, it will use the width of the descriptions that extend past and have a larger width. What's the easiest way to center according to the width of just the stat numbers and still have the descriptions below them?
.container {
text-align: center;
}
.stats {
display: block;
margin: 0 auto 30px auto;
}
.left-stats {
text-align: right;
display: inline-block;
margin-right: 40px;
}
.left-stats .single-stat {
text-align: right;
}
.right-stats {
display: inline-block;
}
.right-stats .single-stat {
text-align: left;
}
.single-stat {
margin-bottom: 20px;
}
.number {
font: 60px"Bebas Neue";
font-weight: bold;
margin-bottom: -5px;
}
<div class="container">
<h3>Header</h3>
<div class="stats">
<div class="left-stats">
<div class="single-stat">
<div class="number">1,200</div>
<div class="desc">Staff on campus supported</div>
</div>
<div class="single-stat">
<div class="number">10</div>
<div class="desc">Departments reached</div>
</div>
</div>
<div class="right-stats">
<div class="single-stat">
<div class="number">06</div>
<div class="desc">Different home states/countries</div>
</div>
<div class="single-stat">
<div class="number">10</div>
<div class="desc">People who love food and technology</div>
</div>
</div>
</div>
</div>
I have a solution using your HTML and using display: table-cell instead of display: inline-block. Instead of a 40px margin to create the space between the columns, I added 20px left/right padding in the relevant elements.
Note that I added dotted blue borders for demonstration purposes, you can remove them.
.container {
text-align: center;
}
.stats {
display: table;
width: 100%;
margin: 0 auto 30px auto;
border: 1px dotted blue;
}
.left-stats {
text-align: right;
display: table-cell;
width: 50%;
padding-right: 20px;
border: 1px dotted blue;
}
.left-stats .single-stat {
text-align: right;
}
.right-stats {
display: table-cell;
width: 50%;
padding-left: 20px;
border: 1px dotted blue;
}
.right-stats .single-stat {
text-align: left;
}
.single-stat {
margin-bottom: 20px;
}
.number {
font: 60px"Bebas Neue";
font-weight: bold;
margin-bottom: -5px;
}
<div class="container">
<h3>Header</h3>
<div class="stats">
<div class="left-stats">
<div class="single-stat">
<div class="number">1,200</div>
<div class="desc">Staff on campus supported</div>
</div>
<div class="single-stat">
<div class="number">10</div>
<div class="desc">Departments reached</div>
</div>
</div>
<div class="right-stats">
<div class="single-stat">
<div class="number">06</div>
<div class="desc">Different home states/countries</div>
</div>
<div class="single-stat">
<div class="number">10</div>
<div class="desc">People who love food and technology</div>
</div>
</div>
</div>
</div>
You mean something like this?
.number {
font: 60px"Bebas Neue";
font-weight: bold;
margin-bottom: -5px;
text-align: center;
}