Here's a basic example of how you can do it:
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>reflow</title>
<style type="text/css">
@media only screen and (min-width: 700px) {
#box {
display:table;
width:80%;
margin:0 auto;
}
.column {
display:table-cell;
background:#ccc;
padding:0 20px;
}
.two {
background:#999;
width:20em;
}
}
@media only screen and (max-width: 700px) {
#box {
width:80%;
margin:0 auto;
}
.column {
width: 100%;
}
}
</style>
<meta name="viewport" content="width=device-width">
</head>
<body>
<h1>Testing column/grids</h1>
<div id="box">
<div class="column">
Main column
</div>
<div class="column two">side bar</div>
</div>
</body>
</html>
If you want a fallback for older browsers (IE8 and under), this is better:
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>reflow</title>
<style type="text/css">
#box {
width:80%;
margin:0 auto;
}
.column {
width: 100%;
}
@media only screen and (min-width: 700px) {
#box {
display:table;
width:80%;
margin:0 auto;
}
.column {
display:table-cell;
background:#ccc;
padding:0 20px;
}
.two {
background:#999;
width:20em;
}
}
</style>
<meta name="viewport" content="width=device-width">
</head>
<body>
<h1>Testing column/grids</h1>
<div id="box">
<div class="column">
Main column
</div>
<div class="column two">side bar</div>
</div>
</body>
</html>
Bookmarks