You can use divs that behave similarly to a row of table-cells.
Here are 3 different ways of addressing them:
Class Everything
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<!--
-->
<head>
<title>class everything</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="content-language" content="en-us">
<style type="text/css">
.table {
display:table;
width:100%;
}
.table div {
display:table-cell;
vertical-align:top;
background-color:#ddd; /* test purposes */
border:1px solid #f00; /* test purposes */
}
.table .cell1 {
text-align:right;
width:49%;
}
.table .cell2 {
text-align:center;
}
.table .cell3 {
text-align:left;
width:49%;
}
img {
display:block;
width:200px;
height:200px;
}
</style>
</head>
<body>
<div class="table">
<div class="cell1"></div>
<div class="cell2"><img src="image.png" alt="not found"></div>
<div class="cell3"></div>
</div>
</body>
</html>
Adjacent Sibling Selector
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<!--
-->
<head>
<title>Adjacent Sibling Selector</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="content-language" content="en-us">
<style type="text/css">
.table {
display:table;
width:100%;
}
.table div { /* all cells */
display:table-cell;
vertical-align:top;
text-align:right;
width:49%;
background-color:#ddd; /* test purposes */
border:1px solid #f00; /* test purposes */
}
.table div + div { /* cells 2 and 3 */
text-align:center;
width:auto;
}
.table div + div + div { /* cell 3 only */
text-align:left;
width:49%;
}
img {
display:block;
width:200px;
height:200px;
}
</style>
</head>
<body>
<div class="table">
<div></div>
<div><img src="image.png" alt="not found"></div>
<div></div>
</div>
</body>
</html>
nth-child pseudoclass
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<!--
-->
<head>
<title>nth-child pseudoclass</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="content-language" content="en-us">
<style type="text/css">
.table {
display:table;
width:100%;
}
.table div { /* all cells */
display:table-cell;
vertical-align:top;
}
.table div:nth-child(1) {
background-color:#fcc; /* test purposes */
text-align:right;
width:49%;
}
.table div:nth-child(2) {
background-color:#ccc; /* test purposes */
text-align:center;
width:auto;
}
.table div:nth-child(3) {
background-color:#ccf; /* test purposes */
text-align:left;
width:49%;
}
img {
display:block;
width:200px;
height:200px;
}
</style>
</head>
<body>
<div class="table">
<div></div>
<div><img src="image.png" alt="not found"></div>
<div></div>
</div>
</body>
</html>
Bookmarks