How to Div Horizontal And Vertical Centering
Category: CSS, CSS Tips, CSS3 Tutorial | 2,822 views | Add a Comment |
I know many people have wondered how to center their content both horizontally and vertically but never managed to find a solution on how to do this using CSS. I have seen people use tables to accomplish this, in this tutorial I will show you how it can be done.
We start off by using an IE (Internet Explorer) hack to make the height of the page 100%.
| html, body { height: 100%; } |
The next part of the code is to give our element an ID. You may find it easier to put whatever content you want centring inside a div tag, I find this works a lot easier, in the end it’s up to you.
CSS Code
| <style type=”text/css”> html, body { height: 100%; } #centeredcontent {
|
We have our ID assigned, now lets move to our HTML and add the code there in the <body> of your page. Read more…
- CSS INCLUDE-SOURCE
- Imports an external style sheet
- CSS ID Selector
- Use shorthand CSS notation
- Organize your CSS-code
- HTML Basics
- CSS Framework
- 150 CSS Examples
- CSS background-size
- Using Logo with CSS





