Vertically centering button using css - html

I am trying to make a simple input button center-align within a table cell.
My markup is:
<table width="500" border="1">
<tr>
<td width="390">XXXXXXXXX</td>
<td width="110" rowspan="2" valign="middle"><input type="button" value="submit"></td>
</tr>
<tr>
<td>YYYYYYYY</td>
</tr>
</table>
<br /><br />
<div style="width:500px;">
<div style="float:left;width:390px;">
<div>XXXXXXX</div>
<div>YYYYYYY</div>
</div>
<div style="vertical-align:middle;width:110px;float:right;">
<div><input type="button" value="submit"></div>
</div>
</div>
I have done a table version showing you the layout that I am trying to achieve. Note that the text represented by "XXXXX" or "YYYYYY" is of variable length.

http://jsfiddle.net/8v8gLn4y/
.container {
background: lightblue;
display: table;
width:100%;
}
input[type=button] {
display: block;
width: 50%;
margin: 0 auto;
}
.button-wrapper {
background: darkorange;
display: table-cell;
vertical-align: middle;
}
<div class='container'>
<div>some line with text</div>
<div>another line with text</div>
<div class='button-wrapper'>
<input type="button" value="submit" />
</div>
</div>
update 2016:
flexbox
.container {
background: bisque;
display: flex;
width: 100%;
}
.container>div {
flex-grow: 1;
}
.button-wrapper {
background: chocolate;
display: flex;
flex-direction: column;
justify-content: center;
}
input[type=button] {
display: block;
width: 50%;
margin: 0 auto;
flex-shrink: 1;
}
<div class='container'>
<div>
<p>some line with text</p>
<p>another line with text</p>
</div>
<div class='button-wrapper'>
<input type="button" value="submit" />
</div>
</div>

If you make your button an inline element and add text-align: center to the parent td you should be fine.
.tools {
text-align: center;
}
.submit {
display: inline;
}
<table width="500" border="1">
<tr>
<td width="390">XXXXXXXXX</td>
<td class="tools" width="110" rowspan="2" valign="middle"><input class- "submit" type="button" value="submit"></td>
</tr>
<tr>
<td>YYYYYYYY</td>
</tr>
</table>
<br /><br />
<div style="width:500px;">
<div style="float:left;width:390px;">
<div>XXXXXXX</div>
<div>YYYYYYY</div>
</div>
<div style="vertical-align:middle;width:110px;float:right;">
<div><input type="button" value="submit"></div>
</div>
</div>

Related

Convert html table row span to CSS

I checked some of the posts here regarding conversion from html table to css but can't find what I am looking and hoping for some help.
I am using a table as a graphical presentation of some lockers that have different sizes. As a result, some table cells span multiple rows. All was fine when there were a few static models. Now I have to deal with dynamic configurations and tables are just a pain, so I am trying to convert it to CSS.
I am running into some problems when cell spans multiple rows and not sure how to set up the CSS. I need to see how it is done statically before attempting to generate the code dynamically.
Here is a short sample:
<table>
<tr>
<td id="Td7" rowspan="4" height="100">R0C0</td>
<td id="Td8" height="25" >R0C1</td>
<td id="Td9" height="25" >R0C2</td>
</tr>
<tr>
<td id="Td10" height="25" >R1C1</td>
<td id="Td11" height="25" >R1C2</td>
</tr>
<tr>
<td id="Td12" height="25" >R2C1</td>
<td id="Td13" height="25" >R2C2</td>
</tr>
<tr>
<td id="Td14" height="25" >R3C1</td>
<td id="Td15" height="25" >R3C2</td>
</tr>
</table>
CSS (Attempt), can get the first row but not sure how to do the rest:
<div>
<span style="display:inline-block;width:100px;height:100px;border:solid 1px black;vertical-align:top;">R0C0</span>
<span style="display:inline-block;width:100px;height:25px;border:solid 1px black;vertical-align:top;">R0C1</span>
<span style="display:inline-block;width:100px;height:25px;border:solid 1px black;vertical-align:top;">R0C2</span>
</div>
Also tried css "table", using the code in one of the posts here:
<style type="text/css">
.css-table {
display: table;
background-color:#ccc;
width: 350px;
}
.css-table-tr {
display: table-row;
}
.css-table-td_small {
display: table-cell;
border:1px solid black;
width: 100px;
height:25px;
display:inline-blok;
text-align:center;
vertical-align:top;
}
.css-table-td_medium {
display: table-cell;
border:1px solid black;
width: 100px;
height:50px;
display:inline-blok;
text-align:center;
vertical-align:top;
}
.css-table-td_large {
display: table-cell;
border:1px solid black;
width: 100px;
height:100px;
display:inline-blok;
text-align:center;
vertical-align:top;
}
.css-table-td_kiosk {
display: table-cell;
border:1px solid black;
width: 100px;
height:150px;
display:inline-blok;
text-align:center;
vertical-align:top;
}
</style>
<div class="css-table">
<div class="css-table-tr">
<span class="css-table-td_kiosk">R0C0</span>
<span class="css-table-td_small">R0C1</span>
<span class="css-table-td_small">R0C2</span>
</div>
</div>
Edit:
This is the (sample) table I need I need to convert. The position and size of lockers will change depending on the model. If I can figure out what one model would look like using CSS, I can work it out to make it dynamic. L, M and S in parenthesis imply locker size. Medium is 2 times small, large is 4 times small and Kiosk is 6 times small locker size.
<table border="1" style="width:600px">
<tr>
<td id="Td1" height="100" >K01D04 (L)</td>
<td id="Td2" height="100" >C02D08 (L)</td>
<td id="Td3" height="100" >C03D08 (L)</td>
</tr>
<tr>
<td id="Td4" height="25" >K01D03 (S)</td>
<td id="Td5" height="25" >C02D07 (S)</td>
<td id="Td6" height="25" >C03D07 (S)</td>
</tr>
<tr>
<td id="Td7" rowspan="5" height="150" class="kPL_Kiosk">KIOSK</td>
<td id="Td8" height="25" >C02D06 (S)</td>
<td id="Td9" height="25" >C03D06(S)</td>
</tr>
<tr>
<td id="Td10" height="25" >C02D05 (S)</td>
<td id="Td11" height="25" >C03D05 (S)</td>
</tr>
<tr>
<td id="Td12" height="25" >C02D04 (S)</td>
<td id="Td13" height="25" >C03D04 (S)</td>
</tr>
<tr>
<td id="Td14" height="25" >C02D03 (S)</td>
<td id="Td15" height="25" >C03D03 (S)</td>
</tr>
<tr>
<td id="Td16" height="50" >C02D02 (M)</td>
<td id="Td17" height="50" >C03D02 (M)</td>
</tr>
<tr>
<td id="Td18" height="50" >K01D02 (M)</td>
<td id="Td19" rowspan="2" height="100" >C02D01 (L)</td>
<td id="Td20" rowspan="2" height="100" >C03D01 (L)</td>
</tr>
<tr>
<td id="Td21" height="50">K01D01 (M)</td>
</tr>
</table>
Thanks.
Edit 2:
The image below shows what I need to display (one variation). L: large locker, height 100 px, M: medium, height 50 px; S: small; height 25 px. However, I do not seem to be able to get the lockers to display column-wise even though I specify flex-direction: column.
Edit 3:
This is the CSS and HTML I am using. Once I added width and height to flex-direction, it started to display the images column-wise. I guess this is an undocumented requirement. However, now everything is displayed in column. This is what I have:
.lockers {
display: flex;
-webkit-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap:wrap;
flex-wrap:wrap;
-webkit-justify-content: space-around;
justify-content: space-around;
align-items: flex-start;
}
.locker-column {
display: flex;
-webkit-flex-direction: column;
flex-direction: column;
-webkit-flex-wrap:wrap;
flex-wrap:wrap;
-webkit-align-items: flex-start;
align-items: flex-start;
height:420px;
width:100px;
}
img {
display: flex;
max-width: 100px;
height: auto;
-webkit-flex-grow:1;
flex-grow:1;
}
<div class="lockers">
<div class="locker-column">
<img src="..\assets\images\Lockers\L.png" title="R1C1-L" />
<img src="..\assets\images\Lockers\S.png" title="R2C1-S" />
<img src="..\assets\images\Lockers\Kiosk.png" title="Kiosk" />
<img src="..\assets\images\Lockers\M.png" title="R4C1-M" />
<img src="..\assets\images\Lockers\M.png" title="R5C1-M" />
</div>
<div class="locker-column">
<img src="..\assets\images\Lockers\L.png" title="R1C2-L" />
<img src="..\assets\images\Lockers\S.png" title="R2C2-S" />
<img src="..\assets\images\Lockers\S.png" title="R2C3-S" />
<img src="..\assets\images\Lockers\S.png" title="R2C4-S" />
<img src="..\assets\images\Lockers\S.png" title="R2C5-S" />
<img src="..\assets\images\Lockers\S.png" title="R2C6-S" />
<img src="..\assets\images\Lockers\M.png" title="R2C7-M" />
<img src="..\assets\images\Lockers\L.png" title="R2C8-L" />
</div>
<div class="locker-column">
<img src="..\assets\images\Lockers\L.png" title="R1C3-L" />
<img src="..\assets\images\Lockers\S.png" title="R2C3-S" />
<img src="..\assets\images\Lockers\S.png" title="R3C3-S" />
<img src="..\assets\images\Lockers\S.png" title="R4C3-S" />
<img src="..\assets\images\Lockers\S.png" title="R5C3-S" />
<img src="..\assets\images\Lockers\S.png" title="R6C3-S" />
<img src="..\assets\images\Lockers\M.png" title="R7C3-M" />
<img src="..\assets\images\Lockers\L.png" title="R8C3-L" />
</div>
</div>
Edit 4:
Don't use display: table. Is this what you're looking for?
Edit: Elaboration
I don't think you're grasping the concept..
I'll try to explain to you how you should be thinking about this. Usually with tables, you're thinking in terms of rows, where that might be the case with flexboxes, when I wrote my solution I was thinking about it in terms of columns.
Notice how I have flex-direction: column on the children of lockers? This div literally spans the entire column, from top to bottom. You can do whatever you want, put whatever lockers you want, of whatever size.
If you have absolutely no experience with flexboxes I recommend you read up on it, but the solution below gives you a core foundation to what you are trying to do.
This tutorial is a good starting point.
.lockers {
display: flex;
justify-content: space-around;
align-items: flex-start;
}
.locker-column {
display: flex;
flex-direction: column;
align-items: stretch;
width: 100px;
}
.locker {
display: flex;
align-items: center;
justify-content: center;
font-size: 22px;
text-decoration: underline;
font-weight: 600;
text-transform: uppercase;
margin: 2px 0;
height: 100%;
}
.large {
background-color: yellow;
color: red;
height: 100px;
}
.small {
background-color: navy;
color: white;
height: 25px;
}
.medium {
background-color: green;
color: red;
height: 50px;
}
.kiosk {
color: red;
text-decoration: none;
text-transform: lowercase;
height: 150px;
}
<div class="lockers">
<div class="locker-column">
<div class="large locker">L11</div>
<div class="small locker">S21</div>
<div class="kiosk locker">Kiosk</div>
<div class="medium locker">M81</div>
<div class="medium locker">M91</div>
</div>
<div class="locker-column">
<div class="large locker">L12</div>
<div class="small locker">S22</div>
<div class="small locker">S32</div>
<div class="small locker">S42</div>
<div class="small locker">S52</div>
<div class="small locker">S62</div>
<div class="medium locker">M72</div>
<div class="large locker">M82</div>
</div>
<div class="locker-column">
<div class="large locker">L13</div>
<div class="small locker">S23</div>
<div class="small locker">S33</div>
<div class="small locker">S43</div>
<div class="small locker">S53</div>
<div class="small locker">S63</div>
<div class="medium locker">M73</div>
<div class="large locker">M83</div>
</div>
</div>

Image 100% height error inside table in Chrome and Safari

I tried pretty hard to find the answer to this on here, on google, and elsewhere, but it seems pretty obscure. I had to do some fancy CSS in order to create a box with a specific aspect ratio inside which a thumbnail would be centered vertically and horizontally. Those are straight-forward ideas that are actually somewhat complicated to implement in CSS. My solution works great everywhere except inside a table in Chrome with an image that has dimensions larger than the container.
Here is code that demonstrates the issue:
/*
sets aspect ratio of container by adding padding that is calculated
according to width of its parent element
*/
.aspect-ratio {
width: 100%;
display: inline-block;
position: relative;
}
.aspect-ratio:after {
padding-top: 76.19%;
display: block;
content: '';
}
/*
parent has no height, this fills the container's space
*/
.fill-container {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
font-size: 0;
}
/*
centers image horizontally and vertically
background color
*/
.image-background {
text-align: center;
background-color: #444;
height: 100%;
width: 100%;
}
.image-background::before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -0.25em;
}
img {
display: inline-block;
padding: 5px;
box-sizing: border-box;
vertical-align: middle;
}
/*
Firefox: image height fills the parent element
Chrome:
inside table - image is rendered at its natural height
outside table - image height fills the parent element as expected
*/
.fill-height {
height: 100%;
}
.fill-width {
width: 100%;
}
/* other styles */
h1, h2, h3 {
text-align: center;
}
table {
width: 100%;
}
.thumbnail-viewer {
width: 40%;
margin: 10px auto;
}
<h1>tall image</h1>
<h2>small</h2>
<h3>table</h3>
<table>
<tbody>
<tr>
<td>
<div class="thumbnail-viewer">
<div class="aspect-ratio">
<div class="fill-container">
<div class="image-background">
<img class="fill-height" src="http://www.irmaagro.com/images/d.jpg" style="height: 100%;">
</div>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<h3>no table</h3>
<div class="thumbnail-viewer">
<div class="aspect-ratio">
<div class="fill-container">
<div class="image-background">
<img class="fill-height" src="http://www.irmaagro.com/images/d.jpg" style="height: 100%;">
</div>
</div>
</div>
</div>
<h2>large</h2>
<h3>table (works in firefox and IE, breaks in chrome and safari)</h3>
<table>
<tbody>
<tr>
<td>
<div class="thumbnail-viewer">
<div class="aspect-ratio">
<div class="fill-container">
<div class="image-background">
<img class="fill-height" src="http://www.landscapeontario.com/thumbnailer.php?image=/assets/1320240573.Twine_wrap_2.JPG&imgWH=500" style="height: 100%;">
</div>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<h3>no table</h3>
<div class="thumbnail-viewer">
<div class="aspect-ratio">
<div class="fill-container">
<div class="image-background">
<img class="fill-height" src="http://www.landscapeontario.com/thumbnailer.php?image=/assets/1320240573.Twine_wrap_2.JPG&imgWH=500" style="height: 100%;">
</div>
</div>
</div>
</div>
<h1>wide image</h1>
<h2>small</h2>
<h3>table</h3>
<table>
<tbody>
<tr>
<td>
<div class="thumbnail-viewer">
<div class="aspect-ratio">
<div class="fill-container">
<div class="image-background">
<img class="fill-width" src="http://www.beach.com/images/activity-photo-county-londonderry-ireland-3-day-lake-district-and-hadrian-s-wall-small-group-tour-from-edinburgh-1.jpg">
</div>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<h3>no table</h3>
<div class="thumbnail-viewer">
<div class="aspect-ratio">
<div class="fill-container">
<div class="image-background">
<img class="fill-width" src="http://www.beach.com/images/activity-photo-county-londonderry-ireland-3-day-lake-district-and-hadrian-s-wall-small-group-tour-from-edinburgh-1.jpg">
</div>
</div>
</div>
</div>
<h2>large</h2>
<h3>table</h3>
<table>
<tbody>
<tr>
<td>
<div class="thumbnail-viewer">
<div class="aspect-ratio">
<div class="fill-container">
<div class="image-background">
<img class="fill-width" src="http://www.craterlaketrust.org/pub/photo/thumb/Crater-Summer_cropto_500x200.JPG">
</div>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<h3>no table</h3>
<div class="thumbnail-viewer">
<div class="aspect-ratio">
<div class="fill-container">
<div class="image-background">
<img class="fill-width" src="http://www.craterlaketrust.org/pub/photo/thumb/Crater-Summer_cropto_500x200.JPG">
</div>
</div>
</div>
</div>
Hopefully as you can see, in Chrome (I'm using 43.0.2357.132 64-bit) and Safari (8.0.7) the tall/large image is exceeding the boundaries of its parent and its height is being set to the natural height of the image. The wide images all work as expected, so this appears to only be an issue of height.
My question: What is a simple or straight-forward way to fix this issue in Chrome and Safari? Or is it a bug and should I look for a less-than-ideal work-around that makes it look less terrible? What is causing this issue?
Thanks!
FYI, on smaller screens (screenwidth < 650px), your first image inside the table breaks as well.
To fix it, change your img to use the absolute positioning centering trick:
img {
padding: 5px;
box-sizing: border-box;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
This also means you don't need the image-background::before declaration.
Why do you need .fill-container to have absolute positioning? If I remove the lines below from styles then everything looks fine in Chrome (I can't test in Safari):
.fill-container {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
font-size: 0;
}
You also haven't closed img tags, you have
<img class="fill-height" src="http://www.irmaagro.com/images/d.jpg" style="height: 100%;">
instead of (notice /> at the end of line)
<img class="fill-height" src="http://www.irmaagro.com/images/d.jpg" style="height: 100%;" />

How to position a div to the bottom of the container?

I need to set <div id="group-of-tables"> to the bottom of the <div class="item-content">, and without using absolute position.
HTML:
<div class="item-content">
<div id="group-of-tables">
<table class="item" id="first-table">
<tr>
<td><div class="" id="">1</div></td>
<td><div class="" id="">2</div></td>
<td><div class="" id="">3</div></td>
<td><div class="" id="">4</div></td>
</tr>
</table>
<table class="item" id="second-table" border="1">
<tr>
<td><div class="" id="">Next</div></td>
</tr>
</table>
</div>
</div>
CSS:
.item-content{
height:100%;
}
Something like this:
You could do it with CSS flex, and don't forget to prefix all the flex related rules to make it to work more browsers, visit this link to see more support details, visit this link to learn more.
JsFiddle Demo
html, body {
height: 100%;
margin: 0;
}
.wrap {
height: 100%;
display: flex;
flex-direction: column;
justify-content: flex-end;
}
.top {
flex: 1;
}
<div class="wrap">
<div class="top">Top</div>
<div class="bottom">Bottom</div>
</div>

How to align a button and a search bar beside each other

I am currently learning HTML and CSS. My problem is: I have a button and a search bar with the search bar currently below the button. I have tried different solutions but to no avail. What should I do so that the button and the search bar are beside each other
Here is my code
<!DOCTYPE html>
<html>
<head>
<title>Sample Dashboard</title>
<style type="text/css">
table, th, td {
border: 1px solid black;
}
p.pos_right {
position: relative;
left: 20px;
}
img {
display: inline-block;
z-index:-1;
}
#mine{
display: inline;
}
</style>
</head>
<body>
<div style="text-align:center;">
<p>Most Number of Referrals for the month of <img src="Red-Ribbon.jpg" alt="redribbon" width="200" height="200" style="vertical-align:top"> </p>
</div>
<div class = "mine" align ="center">
<button style="background-color:yellow" onclick="window.location.reload()"><b>UPDATE</b></button>
<table class = "one" style=border="1" cellpadding="0px" cellspacing="0px">
<tr>
<td style="border-style:solid none solid solid;border-color:#4B7B9F;border-width:1px;">
<input type="text" name="zoom_query" style="width:100px; border:0px solid; height:17px; padding:0px 3px; position:relative;">
</td>
<td style="border-style:solid;border-color:#4B7B9F;border-width:1px;">
<input type="submit" value="" style="border-style: none; background: url('searchbutton3.gif') no-repeat; width: 24px; height: 20px;">
</td>
</tr>
</table>
</div>
</body>
</html>
use .mine not #mine (which is for ID.)
give display:inline-block for childer of mine
.mine>button,.mine>table{
display: inline-block;float:left;
}
table, th, td {
border: 1px solid black;
}
p.pos_right {
position: relative;
left: 20px;
}
img {
display: inline-block;
z-index:-1;
}
.mine>button,.mine>table{
display: inline-block;float:left;
}
refer below code snippet.
<div style="text-align:center;">
<p>Most Number of Referrals for the month of <img src="Red-Ribbon.jpg" alt="redribbon" width="200" height="200" style="vertical-align:top"> </p>
</div>
<div class = "mine" align ="center">
<button style="background-color:yellow" onclick="window.location.reload()"><b>UPDATE</b></button>
<table class = "one" style=border="1" cellpadding="0px" cellspacing="0px">
<tr>
<td style="border-style:solid none solid solid;border-color:#4B7B9F;border-width:1px;">
<input type="text" name="zoom_query" style="width:100px; border:0px solid; height:17px; padding:0px 3px; position:relative;">
</td>
<td style="border-style:solid;border-color:#4B7B9F;border-width:1px;">
<input type="submit" value="" style="border-style: none; background: url('searchbutton3.gif') no-repeat; width: 24px; height: 20px;">
</td>
</tr>
</table>
</div>
One of many ways to achieve this would be to put the button in its own
<td>
tag inside the row of the table. I.e.
<table class = "one" style=border="1" cellpadding="0px" cellspacing="0px">
<tr>
<td>
<button style="background-color:yellow" onclick="window.location.reload()"><b>UPDATE</b></button>
</td>
...
See https://jsfiddle.net/orndorffgrant/189judf0/
.
The reason that there was a line break is that there is an implicit line break before and after every table.

How to set div and text to vertical middle of it parent

I have a two divs it's containing in parent div. first div at left side and second at right.
So, i want a right div at middle of parent with out using margin.
HTML
<div class="clearfix" style="background-color: #CCCCCC;">
<div style="padding: 10px; background-color: #0099FF;" class="inline-block">
<div class="inline-block"><div>Post</div><div>139</div></div>
<div class="inline-block"><div>Following</div><div>139</div></div>
<div class="inline-block"><div>Followers</div><div>139</div></div>
</div>
<div class="rfloat" style="background-color: #00FF66; display: table-cell; vertical-align: middle;">
Follow
Message
Report
</div>
</div>
CSS
.inline-block {
display: inline-block;
}
.rfloat {
float: right;
}
.lfloat {
float: left;
}
.clearfix:before,
.clearfix:after {
display: table;
content: " ";
}
.clearfix:after {
clear: both;
}
and here's jsfiddle http://jsfiddle.net/fmr3Y/
This how you can do it
DEMO
HTML
<div class="rfloat" style="background-color: #00FF66; display: table; height: 60px">
CSS
a {
display: table-cell;
vertical-align: middle;
}
Use display:table -- demo
<div class="clearfix" style="background-color: #CCCCCC; display:table;width:100%;">
<div style="padding: 10px; background-color: #0099FF;" class="inline-block">
<div class="inline-block">
<div>Post</div>
<div>139</div>
</div>
<div class="inline-block">
<div>Following</div>
<div>139</div>
</div>
<div class="inline-block">
<div>Followers</div>
<div>139</div>
</div>
</div>
<div class="ss" style="background-color: #00FF66; display: table-cell; vertical-align: middle;"> Report
Message
Follow
</div>
</div>
You could mimic the flex justify-content with display and text-align:justify : DEMO
.inline-block {
display: inline-block;
font-size:16px;/* do not forget to reset font-size to childs*/
font-size:1rem;
text-align:center;/* left, right, .. */
}
.justify:after {
display: inline-table;
content: " ";
width:100%;
height:0;
vertical-align:top;/* no extra gap please */
}
.justify {
text-align:justify;/* will span element from one side to the other */
font-size:0;/* reduce line-height and avoid gap from pseudo element */
}
HTML updated with class name :
<div class="justify" style="background-color: #CCCCCC;">
<div style="padding: 10px; background-color: #0099FF;vertical-align: middle;" class="inline-block">
<div class="inline-block"><div>Post</div><div>139</div></div>
<div class="inline-block"><div>Following</div><div>139</div></div>
<div class="inline-block"><div>Followers</div><div>139</div></div>
</div>
<div class="inline-block" style="background-color: #00FF66; vertical-align: middle;">
Follow
Message
Report
</div>
</div>
I had Changed Your structure to make Right Div at center
<table class="clearfix" style="background-color: #CCCCCC; width: 100%;text-align: center; ">
<colgroup>
<col style="width: 19%"/>
<col style="width: 75%"/>
</colgroup>
<tr>
<td>
<div style="padding: 10px; background-color: #0099FF;" class="inline-block">
<div class="inline-block">
<div>Post</div>
<div>139</div>
</div>
<div class="inline-block">
<div>Following</div>
<div>139</div>
</div>
<div class="inline-block">
<div>Followers</div>
<div>139</div>
</div>
</div>
</td>
<td>
<div style="background-color: #00FF66; vertical-align: middle;">
Follow
Message
Report
</div>
</td>
</tr>
</table>
Here is Working Demo Too.Working Fiddle