Skip to content

Instantly share code, notes, and snippets.

@projectxcappe
Created October 4, 2011 22:05
Show Gist options
  • Save projectxcappe/1262974 to your computer and use it in GitHub Desktop.
Save projectxcappe/1262974 to your computer and use it in GitHub Desktop.
CSS Divs
<head>
<title>Horizontally Align Divs with CSS</title>
<style type="text/css">
html,body{
height: 100%;
width: 100%;
margin:0;
padding:0;
}
.wrapper_div {
width:600px;
height:300px;
}
.left_div {
float:left;
height:100%;
width:25%;
background-color:#03C;
}
.mid_div {
float:left;
height:100%;
width:25%;
background-color:#3C3;
}
.mid2_div {
float:left;
height:100%;
width:25%;
background-color:#60C;
}
.right_div {
float:left;
height:100%;
width:25%;
background-color:#99C;
}
</style>
</head>
<body>
<div class="wrapper_div">
<div class="left_div"></div>
<div class="mid_div"></div>
<div class="mid2_div"></div>
<div class="right_div"></div>
</div>
</body>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Vertically Align Divs with CSS</title>
<style type="text/css">
html,body{
height: 100%;
width: 100%;
margin:0;
padding:0;
}
.wrapper_div {
width:300px;
height:300px;
}
.top_div {
height: 25%;
background-color:#03C;
}
.mid_div {
height: 25%;
background-color:#3C3;
}
.mid2_div {
height: 25%;
background-color:#006;
}
.btm_div {
height: 25%;
background-color:#99C;
}
</style>
</head>
<body>
<div class="wrapper_div">
<div class="top_div"></div>
<div class="mid_div"></div>
<div class="mid2_div"></div>
<div class="btm_div"></div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment