-1

I've tried about 6-7 different methods for centering this text vertically so it remains responsive and in the center of the div.

here is a fiddle: http://jsfiddle.net/p2NLK/

I've tried using positioning such as

margin-top: 40%;

or

margin-top: 20em;

to the h1 element to push the text down but its not fluid at all and breaks a lot.

MikaAK
  • 2,334
  • 6
  • 26
  • 53
  • Possible dupe http://stackoverflow.com/q/20763508/703717 – Danield Mar 12 '14 at 07:27
  • Take a look at [this](http://stackoverflow.com/questions/8865458/how-to-align-text-vertically-center-in-div-with-css?rq=1#answer-8865463a) answer. It has some solutions. – Muhammad Osmond Mar 12 '14 at 07:32
  • Ok I've already tried all these techniques because my container is a position absolute this doesn't seem to work. – MikaAK Mar 12 '14 at 07:37

2 Answers2

2

Have you tried

<div style="text-align: center;">

Works for horizontal center.

Try this for vertically centered.

or

CSS

body, html, #wrapper {
width: 100%;
height: 100%
}

#wrapper {
display: table
}

#main {
display: table-cell;
vertical-align: middle;
text-align:center
}

HTML

<div id="wrapper">
<div id="main">
Content goes here
</div>
</div>

Hope this helps. Do leave a feed back.

0

try this:

replace margin-top: 40%; to following css

display: table-cell;
vertical-align: middle;
text-align:center;
Mr.G
  • 3,413
  • 2
  • 16
  • 20