My inline-block divs are displayed in strange zig-zag pattern - css

I'm trying to visualise simple commands and their arguments in HTML. Desired output:
Actual output:
The code I used:
html {
background-color: #222;
}
div.script {
display: table-cell;
vertical-align: top;
}
div.script div.script-command {
display: inline-block;
max-width: 10em;
min-width:3em;
border: 1px solid #66E239;
background-color: rgba(102,226,57, 0.3);
border-radius: 0.5 em;
}
div.script-command p.name {
text-align: center;
font-size: 15pt;
}
div.script-command div.arguments {
padding: 0.5 em;
text-align: center;
}
div.script-command div.arguments .argument {
font-family: "Courier new", consolas;
color: black;
font-size:11pt;
background-color: #CCC;
border: 1px solid white;
padding: 3pt;
margin: 2pt;
display: inline-block;
}
<div class="script">
<div class="script-command">
<p class="name">s
</p>
<hr>
<div class="arguments">
<span class="argument">xxx
</span>
</div>
</div>
<div class="script-command">
<p class="name">aaa
</p>
<hr>
<div class="arguments">
</div>
</div>
<div class="script-command">
<p class="name">s
</p>
<hr>
<div class="arguments">
<span class="argument">gfdgf
</span>
<span class="argument">1000
</span>
<span class="argument">5
</span>
</div>
</div>
<div class="script-command">
<p class="name">dd\;
</p>
<hr>
<div class="arguments">
</div>
</div>
</div>
The wrong alignment happens when the .arguments div is empty. Why does it happen? How do I fix it?

Use vertical-align: top; on your inline-block elements.

You need to set the vertical-alignment of the inline-block element.
If you want to glance at the spec,
This shorthand property specifies how an inline-level box is aligned within the line. Values are the same as for its longhand properties, see below.
Since you have the baseline set as default/not specifically set, it will style to the lowest line, and hence by setting it to top will align the inline-block elements to the top line.
html {
background-color: #222;
}
div.script {
display: table-cell;
vertical-align: top;
}
div.script div.script-command {
display: inline-block;
max-width: 10em;
min-width:3em;
vertical-align: top;
border: 1px solid #66E239;
background-color: rgba(102,226,57, 0.3);
border-radius: 0.5 em;
}
div.script-command p.name {
text-align: center;
font-size: 15pt;
}
div.script-command div.arguments {
padding: 0.5 em;
text-align: center;
}
div.script-command div.arguments .argument {
font-family: "Courier new", consolas;
color: black;
font-size:11pt;
background-color: #CCC;
border: 1px solid white;
padding: 3pt;
margin: 2pt;
display: inline-block;
}
<div class="script">
<div class="script-command">
<p class="name">s
</p>
<hr>
<div class="arguments">
<span class="argument">xxx
</span>
</div>
</div>
<div class="script-command">
<p class="name">aaa
</p>
<hr>
<div class="arguments">
</div>
</div>
<div class="script-command">
<p class="name">s
</p>
<hr>
<div class="arguments">
<span class="argument">gfdgf
</span>
<span class="argument">1000
</span>
<span class="argument">5
</span>
</div>
</div>
<div class="script-command">
<p class="name">dd\;
</p>
<hr>
<div class="arguments">
</div>
</div>
</div>

checkout this fix
div.script div.script-command {
display: inline-block;
max-width: 10em;
min-width:3em;
vertical-align:top;
border: 1px solid #66E239;
background-color: rgba(102,226,57, 0.3);
border-radius: 0.5 em;
}
http://jsfiddle.net/jrpq1xe7/

Related

Why borders are getting chopped in safari browser?

I am trying to achieve borders on each print page, on chrome it works fine but in safari border is getting chopped.
I have created a div which is fixed. That div has borders so when window print is triggered, borders comes on all the pages on chrome, but not on safari.
Anyone has solution for this??
my code:
<div class="loading-mask" data-role="loader" style="display: none !important">
<div class="loader">
</div>
</div>
<div class="cutom-container"></div>
<div class="content-div">
<div>
<div class="logo-content">
<div class="logo-div">
<img class="print-logo" src="<?= $this->getViewFileUrl('images/cart-page-print-logo.png'); ?>" alt="<?= __('Print Header Logo'); ?>"/>
<p>
----- </h3>
</p>
<div class="input-container">
<label>Company Name : </label><span id="pcname"> </span>
</div>
<div class="input-container">
<label>Contact : </label><span id="pcontact"> </span>
</div>
<div class="input-container">
<label>Phone : </label><span id="pphone"> </span>
</div>
</div>
</div>
<div class="img-content">
<img class="promotional-img" src="<?= $this->getViewFileUrl('images/PRT-offer graphic.png'); ?>" alt="<?= __('Print Offer'); ?>"/>
</div>
</div>
<div>
<div class="input-container">
<label>Email : </label><span id="pemail"> </span>
</div>
<div class="input-container">
<label>Delivery Address : </label><span id="daddress"> </span>
</div>
<div class="input-container">
<label>Mailing Address : </label><span id="maddress"> </span>
</div>
</div>
<div>
<table id="product-list-print">
</table>
</div>
<div id="sub-total-print">
</div>
<div>
<div class="logo-content">
<p>
Shipping (Shipping rates are appox and apply to US Mainland ONLY)</br> - Please see Sales Specialist for exact quote. Shipping rates for Aff ordable Advantage Trailers do not apply. Park Model Units will require additional shipping fee. <strong>Estimate is valid for 7 days.</strong>
</p>
</div>
<div class="img-content">
<div>
To order this unit sign here
</div>
<div>
<canvas id="myCanvas" style="width: 100%">Your browser does not support the HTML5 canvas tag.</canvas>
</div>
</div>
</div>
</div>
css :
/* Print page css */
.cutom-container{
border : solid #670827 5px;
border-radius: 10px;
position:fixed;
overflow: auto;
left: 0;
right: 0;
top: 0;
bottom: 0;
display: none;
/*border: 5px solid red;*/
}
.content-div{
padding: 10px 5px 5px 5px;
display: none;
}
.logo-content{
display: inline-block;
width: 64%
}
.img-content{
display: inline-block;
width: 35%
}
.print-logo{
width: 50%;
}
.logo-div{
text-align: center;
}
.promotional-img{
width: 100%;
}
.img-content{
text-align: center;
}
.input-container{
padding: 8px;
text-align: left;
border:solid #670827 1px;
font-size: 15px;
margin: 10px;
}
/* end */
.warranty-container{
padding: 10px;
font-size: 16px;
border: solid;
border-width: 1px;
}
.cart-product-warrenty{
display: none;
}
.center-align{
text-align: center;
}
#signArea{
margin-bottom:20px ;
}
#media print {
#page {
border : solid #670827 5px;
border-radius: 10px; }
.cart-container{
display: none;
}
.cutom-container{
display: block !important;
padding: 15px;
}
.content-div{
display: block !important;
padding: 15px;
}
.cart-product-warrenty{
display: contents;
}
.summary.title{
display: none;
}
#sub-total-print>.fieldset{
display: none;
}
#block-shipping{
display: none;
}
input.qty{
width: 50px !important;
padding: 0 !important;
text-align: center;
}
.product-item-name{
text-decoration: unset;
font-size: 1.8rem;
line-height: 1;
font-weight: 700;
padding-top: 0px;
}
.messages{
display: none;
}
a{
text-decoration: none !important;
}
}
#media only screen and (max-width: 600px) {
.modal-content{
width: 80%;
}
.current{
width: 250px !important;
}
.sign-pad{
width: 247px !important;
}
.modal-content{
margin-bottom: 55px;
}
.cart-product-warrenty{
display: none;
}
}

Why is <ul> getting out of the box when padding is set to zero?

This containers are arranged using nested flexbox. When I added an unordered list with zero padding, it got outside the child container. Not only that it also goes outside the parent container.
:root {
--main-bg-color: #3D3E5D;
--bg-color-red: #F06D4F;
--bg-color-aqua: #2DA6A4;
--bg-color-orange: #EFB85E;
--txt-color-primary: black;
--txt-color-secondary: white;
--heading: 3rem;
--sub-heading: 2rem;
--normal: 1rem;
--small: 0.5rem;
--main-padding: 10px;
}
* {
margin: none;
padding: 0;
box-sizing: border-box;
}
.container__main {
width: 90%;
margin: auto;
}
.container__flex {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.flex__box {
font-weight: 900;
font-size: var(--normal);
background-color: aqua;
flex: 0 0 calc(50% - 10px);
}
.red {
background-color: red;
}
.gray {
background-color: gray;
}
.container__main>.container__flex {
margin-bottom: 10px;
}
.container__flex>.flex__box {
padding: var(--main-padding);
}
.p-0 {
padding: 0 !important;
}
<div class="container__main">
<div class="container__flex">
<div class="flex__box">
<b></b>
<span class="heading">W</span>eb <span class="heading">A</span>pplication <span class="heading">T</span>echnologies
</div>
<div class="flex__box gray">
<div class="container__flex">
<div class="flex__box p-0 red">
<span class="sub-heading">Links</span>
<ul>
<li>Chubkins</li>
<li>W3 Schools</li>
<li>Learn Web Dev</li>
<li>Colour Reference</li>
</ul>
</div>
<div class="flex__box p-0 red">
</div>
</div>
</div>
</div>
<div class="container__flex">
<div class='flex__box'>
box1
</div>
<div class='flex__box'>
box2
</div>
</div>
</div>
Picture of the mentioned problem: https://prnt.sc/plgv0y
If you want to help me debug this view this codepen link:
https://codepen.io/bishant-bhattarai/pen/qBBqqYE
Since this was a small project I didn't add any comments, sorry for inconvineince.
This is probably due to the default value of the CSS property list-style-position.
You can try and change that like this:
:root {
--main-bg-color: #3D3E5D;
--bg-color-red: #F06D4F;
--bg-color-aqua: #2DA6A4;
--bg-color-orange: #EFB85E;
--txt-color-primary: black;
--txt-color-secondary: white;
--heading: 3rem;
--sub-heading: 2rem;
--normal: 1rem;
--small: 0.5rem;
--main-padding: 10px;
}
* {
margin: none;
padding: 0;
box-sizing: border-box;
}
.container__main {
width: 90%;
margin: auto;
}
.container__flex {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.flex__box {
font-weight: 900;
font-size: var(--normal);
background-color: aqua;
flex: 0 0 calc(50% - 10px);
}
.red {
background-color: red;
}
.gray {
background-color: gray;
}
.container__main>.container__flex {
margin-bottom: 10px;
}
.container__flex>.flex__box {
padding: var(--main-padding);
}
.p-0 {
padding: 0 !important;
}
ul {
list-style-position: inside;
}
<div class="container__main">
<div class="container__flex">
<div class="flex__box">
<b></b>
<span class="heading">W</span>eb <span class="heading">A</span>pplication <span class="heading">T</span>echnologies
</div>
<div class="flex__box gray">
<div class="container__flex">
<div class="flex__box p-0 red">
<span class="sub-heading">Links</span>
<ul>
<li>Chubkins</li>
<li>W3 Schools</li>
<li>Learn Web Dev</li>
<li>Colour Reference</li>
</ul>
</div>
<div class="flex__box p-0 red">
</div>
</div>
</div>
</div>
<div class="container__flex">
<div class='flex__box'>
box1
</div>
<div class='flex__box'>
box2
</div>
</div>
</div>
cf. https://developer.mozilla.org/en-US/docs/Web/CSS/list-style-position

How do i align items in a list to look like a chat

Vue chat application
I'm creating this chat app like a little project, but I can't make the messages align properly. The messages sent by the user (light blue) should be on the right side, the CSS looks like:
.received {
text-align: left;
background-color: #0A2472;
margin: 1%;
color: white;
padding: 1%;
max-width: fit-content;
}
.sent {
text-align: right;
align-content: right;
background-color: #A6E1FA;
margin: 1%;
padding: 1%;
max-width: fit-content;
}
It looks fine, until "max-width: fit-content" is added to the style.
Any solutions or other approaches?
The main problem is that your messages are only as wide as their text, so the alignment doesn't matter.
I made a container to hold them. I like CSS Grid for laying out almost everything. The chat messages are just rows in the grid, some justified left and some right.
.chatboard {
display: grid;
width: 100%;
grid-gap: 0.6rem;
max-width: 40rem;
}
.sent,
.received {
padding: 1%;
min-width: 20rem;
border-radius: 0.6rem;
}
.received {
justify-self: left;
background-color: #0A2472;
color: white;
}
.sent {
text-align: right;
justify-self: right;
align-content: right;
background-color: #A6E1FA;
}
<div class="chatboard">
<div class="received">Hi there</div>
<div class="sent">Hello there</div>
<div class="received">Hi there</div>
<div class="sent">Hello there</div>
<div class="received">Hi there</div>
<div class="sent">Hello there</div>
</div>
I have an example of how you can achieve this. I will paste the code below. Look in the css for the specific style you want. It looks like the style rules would be the style modifying the <p> tag in the example the specific css rules modifying it are
display: block;
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
here is the html
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" type="text/css" rel="stylesheet"
</head>
<body>
<div class="container">
<h3 class=" text-center">Messaging</h3>
<div class="messaging">
<div class="inbox_msg">
<div class="inbox_people">
<div class="headind_srch">
<div class="recent_heading">
<h4>Recent</h4>
</div>
<div class="srch_bar">
<div class="stylish-input-group">
<input type="text" class="search-bar" placeholder="Search" >
<span class="input-group-addon">
<button type="button"> <i class="fa fa-search" aria-hidden="true"></i> </button>
</span> </div>
</div>
</div>
<div class="inbox_chat">
<div class="chat_list active_chat">
<div class="chat_people">
<div class="chat_img"> <img src="https://ptetutorials.com/images/user-profile.png" alt="sunil"> </div>
<div class="chat_ib">
<h5>Sunil Rajput <span class="chat_date">Dec 25</span></h5>
<p>Test, which is a new approach to have all solutions
astrology under one roof.</p>
</div>
</div>
</div>
<div class="chat_list">
<div class="chat_people">
<div class="chat_img"> <img src="https://ptetutorials.com/images/user-profile.png" alt="sunil"> </div>
<div class="chat_ib">
<h5>Sunil Rajput <span class="chat_date">Dec 25</span></h5>
<p>Test, which is a new approach to have all solutions
astrology under one roof.</p>
</div>
</div>
</div>
<div class="chat_list">
<div class="chat_people">
<div class="chat_img"> <img src="https://ptetutorials.com/images/user-profile.png" alt="sunil"> </div>
<div class="chat_ib">
<h5>Sunil Rajput <span class="chat_date">Dec 25</span></h5>
<p>Test, which is a new approach to have all solutions
astrology under one roof.</p>
</div>
</div>
</div>
<div class="chat_list">
<div class="chat_people">
<div class="chat_img"> <img src="https://ptetutorials.com/images/user-profile.png" alt="sunil"> </div>
<div class="chat_ib">
<h5>Sunil Rajput <span class="chat_date">Dec 25</span></h5>
<p>Test, which is a new approach to have all solutions
astrology under one roof.</p>
</div>
</div>
</div>
<div class="chat_list">
<div class="chat_people">
<div class="chat_img"> <img src="https://ptetutorials.com/images/user-profile.png" alt="sunil"> </div>
<div class="chat_ib">
<h5>Sunil Rajput <span class="chat_date">Dec 25</span></h5>
<p>Test, which is a new approach to have all solutions
astrology under one roof.</p>
</div>
</div>
</div>
<div class="chat_list">
<div class="chat_people">
<div class="chat_img"> <img src="https://ptetutorials.com/images/user-profile.png" alt="sunil"> </div>
<div class="chat_ib">
<h5>Sunil Rajput <span class="chat_date">Dec 25</span></h5>
<p>Test, which is a new approach to have all solutions
astrology under one roof.</p>
</div>
</div>
</div>
<div class="chat_list">
<div class="chat_people">
<div class="chat_img"> <img src="https://ptetutorials.com/images/user-profile.png" alt="sunil"> </div>
<div class="chat_ib">
<h5>Sunil Rajput <span class="chat_date">Dec 25</span></h5>
<p>Test, which is a new approach to have all solutions
astrology under one roof.</p>
</div>
</div>
</div>
</div>
</div>
<div class="mesgs">
<div class="msg_history">
<div class="incoming_msg">
<div class="incoming_msg_img"> <img src="https://ptetutorials.com/images/user-profile.png" alt="sunil"> </div>
<div class="received_msg">
<div class="received_withd_msg">
<p>Test which is a new approach to have all
solutions</p>
<span class="time_date"> 11:01 AM | June 9</span></div>
</div>
</div>
<div class="outgoing_msg">
<div class="sent_msg">
<p>Test which is a new approach to have all
solutions</p>
<span class="time_date"> 11:01 AM | June 9</span> </div>
</div>
<div class="incoming_msg">
<div class="incoming_msg_img"> <img src="https://ptetutorials.com/images/user-profile.png" alt="sunil"> </div>
<div class="received_msg">
<div class="received_withd_msg">
<p>Test, which is a new approach to have</p>
<span class="time_date"> 11:01 AM | Yesterday</span></div>
</div>
</div>
<div class="outgoing_msg">
<div class="sent_msg">
<p>Apollo University, Delhi, India Test</p>
<span class="time_date"> 11:01 AM | Today</span> </div>
</div>
<div class="incoming_msg">
<div class="incoming_msg_img"> <img src="https://ptetutorials.com/images/user-profile.png" alt="sunil"> </div>
<div class="received_msg">
<div class="received_withd_msg">
<p>We work directly with our designers and suppliers,
and sell direct to you, which means quality, exclusive
products, at a price anyone can afford.</p>
<span class="time_date"> 11:01 AM | Today</span></div>
</div>
</div>
</div>
<div class="type_msg">
<div class="input_msg_write">
<input type="text" class="write_msg" placeholder="Type a message" />
<button class="msg_send_btn" type="button"><i class="fa fa-paper-plane-o" aria-hidden="true"></i></button>
</div>
</div>
</div>
</div>
<p class="text-center top_spac"> Design by <a target="_blank" href="#">Sunil Rajput</a></p>
here is the css
.container{max-width:1170px; margin:auto;}
img{ max-width:100%;}
.inbox_people {
background: #f8f8f8 none repeat scroll 0 0;
float: left;
overflow: hidden;
width: 40%; border-right:1px solid #c4c4c4;
}
.inbox_msg {
border: 1px solid #c4c4c4;
clear: both;
overflow: hidden;
}
.top_spac{ margin: 20px 0 0;}
.recent_heading {float: left; width:40%;}
.srch_bar {
display: inline-block;
text-align: right;
width: 60%; padding:
}
.headind_srch{ padding:10px 29px 10px 20px; overflow:hidden; border-bottom:1px solid #c4c4c4;}
.recent_heading h4 {
color: #05728f;
font-size: 21px;
margin: auto;
}
.srch_bar input{ border:1px solid #cdcdcd; border-width:0 0 1px 0; width:80%; padding:2px 0 4px 6px; background:none;}
.srch_bar .input-group-addon button {
background: rgba(0, 0, 0, 0) none repeat scroll 0 0;
border: medium none;
padding: 0;
color: #707070;
font-size: 18px;
}
.srch_bar .input-group-addon { margin: 0 0 0 -27px;}
.chat_ib h5{ font-size:15px; color:#464646; margin:0 0 8px 0;}
.chat_ib h5 span{ font-size:13px; float:right;}
.chat_ib p{ font-size:14px; color:#989898; margin:auto}
.chat_img {
float: left;
width: 11%;
}
.chat_ib {
float: left;
padding: 0 0 0 15px;
width: 88%;
}
.chat_people{ overflow:hidden; clear:both;}
.chat_list {
border-bottom: 1px solid #c4c4c4;
margin: 0;
padding: 18px 16px 10px;
}
.inbox_chat { height: 550px; overflow-y: scroll;}
.active_chat{ background:#ebebeb;}
.incoming_msg_img {
display: inline-block;
width: 6%;
}
.received_msg {
display: inline-block;
padding: 0 0 0 10px;
vertical-align: top;
width: 92%;
}
.received_withd_msg p {
background: #ebebeb none repeat scroll 0 0;
border-radius: 3px;
color: #646464;
font-size: 14px;
margin: 0;
padding: 5px 10px 5px 12px;
width: 100%;
}
.time_date {
color: #747474;
display: block;
font-size: 12px;
margin: 8px 0 0;
}
.received_withd_msg { width: 57%;}
.mesgs {
float: left;
padding: 30px 15px 0 25px;
width: 60%;
}
.sent_msg p {
background: #05728f none repeat scroll 0 0;
border-radius: 3px;
font-size: 14px;
margin: 0; color:#fff;
padding: 5px 10px 5px 12px;
width:100%;
}
.outgoing_msg{ overflow:hidden; margin:26px 0 26px;}
.sent_msg {
float: right;
width: 46%;
}
.input_msg_write input {
background: rgba(0, 0, 0, 0) none repeat scroll 0 0;
border: medium none;
color: #4c4c4c;
font-size: 15px;
min-height: 48px;
width: 100%;
}
.type_msg {border-top: 1px solid #c4c4c4;position: relative;}
.msg_send_btn {
background: #05728f none repeat scroll 0 0;
border: medium none;
border-radius: 50%;
color: #fff;
cursor: pointer;
font-size: 17px;
height: 33px;
position: absolute;
right: 0;
top: 11px;
width: 33px;
}
.messaging { padding: 0 0 50px 0;}
.msg_history {
height: 516px;
overflow-y: auto;
}

Bootstrap - Button being pushed down a row

I'm having issues with my bootstrap code. When I re-size the screen the button is being pushed down outside of the row and container. It seems the container class isn't even being used. Where did I go wrong here? Thank you.
#cta-center {
line-height: 90px;
}
#cta-bg {
background: gray;
height: 90px;
}
.cta p {
text-align: center;
font-size: 35px;
font-weight: 600;
color: #fff;
}
.btn-primary {
width: 200px;
height: 50px;
background: yellow;
}
.btn-primary p {
color: #000;
line-height: 34px;
font-size: 25px;
font-weight: 600;
}
<div id="cta-center">
<div id="cta-bg">
<div class="container">
<div class="row">
<div class="cold-md-12">
<div class="col-md-8">
<div class="cta">
<p>Get a FREE Quote NOW</p>
</div>
</div>
<div class="col-md-4">
<a href="#" class="btn btn-primary">
<p>CLICK HERE</p>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
Image:

Horizontal centering of div within display:table row

I have a layout composed of divs displaying as table, 3 table rows, and up to 5 table cells per row. My problem is twlofold:
1) I can't figure out how to center the table cells within the rows if there are less than five cells in the table., and
2) I can't figure out how to keep the integrity of the shapes when there are less than 5 in a row.
The number of cells in a row will be variable (between 3 and 5), and I have to use divs -- I can't use real tables.
Here is a codepen: http://codepen.io/Jaemaz/full/aCboe
Here is the source:
HTML:
<div class="focus-container">
<div class="focus-row">
<div class="focus-element circle">
<span class="ng-scope">
Option A
</span>
</div>
<div class="focus-element circle">
<span class="ng-scope">
Option B
</span>
</div>
<div class="focus-element circle">
<span class="ng-scope">
Option C
</span>
</div>
<div class="focus-element circle">
<span class="ng-scope">
Option D
</span>
</div>
<div class="focus-element circle">
<span class="ng-scope">
Option E
</span>
</div>
</div>
<div class="focus-row">
<div class="focus-element circle" ng-class="{unknown: unknown, square: square, circle: circle, selected: selected, shouldHaveBeenSelected: shouldHaveBeenSelected, shouldNotHaveBeenSelected: shouldNotHaveBeenSelected}" ng-click="click()" ng-transclude="" focuschoice="" identifier="F" enabled="true">
<span class="ng-scope">
Option F
</span>
</div>
</div>
</div>
CSS:
.focus-container {
width: 560px;
height: auto;
display: table;
background-color: #000;
border-spacing: 15px;
table-layout: fixed;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
user-select: none;
}
.focus-row {
width: 100%;
height: 100%;
display: table-row;
}
.focus-element {
width: 90px;
height: 90px;
display: table-cell;
color: #fff;
background: #808080;
border: 2px solid #BFBFBF;
vertical-align: middle;
text-align: center;
font-family: "Ubuntu", Arial, Helvetica, sans-serif;
font-size: 14px;
text-shadow: 0px 2px 1px rgba(0, 0, 0, 1);
max-width: 94px;
}
.focus-element.circle {
-moz-border-radius: 94px;
-webkit-border-radius: 94px;
border-radius: 94px;
}
Screen Shot:
Tables won't do that, but tables in table will. 1) Use single-cell rows in outer table and a new table within each cell, and center the inner table within the row. 2) You might use fixed (or some relative) width and height on each cell within inner tables.
ADDED:
This will work for display:table as well as old-school table.
Outermost table should only have one cell in each row, and in that cell place the inner table.
Building on #Jojje 's suggestion, the answer lies in creating an extra "inner" level (display:table) within the div structure. Solution is on CodePen here: http://codepen.io/Jaemaz/pen/spbKf
In case Codepen goes away, here is sample HTML and CSS:
HTML
<div class="focus-container">
<div class="focus-row">
<div class="inner">
<div class="focus-element circle">
<span>ahem</span>
</div>
</div>
</div>
<div class="focus-row">
<div class="inner">
<div class="focus-element circle">
<span>hello</span>
</div>
<div class="focus-element circle">
<span>there</span>
</div>
</div>
</div>
<div class="focus-row">
<div class="inner">
<div class="focus-element circle">
<span>what</span>
</div>
<div class="focus-element circle">
<span class="content">is</span>
</div>
<div class="focus-element circle">
<span>happening</span>
</div>
<div class="focus-element circle">
<span>happening</span>
</div>
<div class="focus-element circle">
<span>happening</span>
</div>
</div>
</div>
</div>
CSS
.focus-container {
width: 560px;
background-color: #000;
padding: 5px;
}
.focus-container .focus-row {
height: 110px;
background-color: #000
}
.focus-container .focus-row .inner {
display: table;
margin: 0 auto;
height: 110px;
}
.focus-container .focus-row .inner .focus-element {
float: left;
text-align: center;
margin: 0 auto;
width: 94px;
height: 94px;
background-color: #009900;
}
.focus-container .focus-row .inner .focus-element span {
margin-top: 40px;
display: block;
}
.focus-container .focus-row .inner .circle {
-moz-border-radius: 94px;
-webkit-border-radius: 94px;
border-radius: 94px;
margin: 8px;

Resources