0

This is my HTML:

<div class="fourcol" align="center" ;="" style="float:;">
<h2 class="center" style="text-align: center;">More Mentors Announced Soon</h2>

The text itself is center justified, but I want it to be horizontally centered within the page. How can I do this?

This is the CSS I've been using with it

.fourcol, {
    position: relative;
    float: left;
    margin-right: 2.762430939%;
    margin-bottom: 20px;
    margin-top: 20px; 
}


h2.center {
    width: 50%;
    margin: 0 auto;
codingrose
  • 15,563
  • 11
  • 39
  • 58
Kakarotto57
  • 59
  • 1
  • 5
  • 1
    possible duplicate of [How to center text horizontally and vertically?](http://stackoverflow.com/questions/19461521/how-to-center-text-horizontally-and-vertically) – Josh Crozier Jan 11 '14 at 01:10

2 Answers2

2

try this one.change class fourcol to more

.more {
    float: left;
    width: 100%;
}
<div align="center" class="more">
<h2 style="text-align: center;" class="center">More Mentors Announced Soon</h2>
</div>
radha
  • 782
  • 4
  • 8
0

http://jsfiddle.net/aDdge/

Just remove the width 50% line

h2.center {
    width: 50%; //remove this line
    margin: 0 auto;
}

EDIT

http://jsfiddle.net/aDdge/2/

h2.center {
    margin-top: 34%;
}
CRABOLO
  • 8,605
  • 39
  • 41
  • 68
  • Hi, Thank you for the help. Unfortunately it still isn't working. I've pasted the full CSS/HTML here http://jsfiddle.net/RiverTam/sLK83/ – Kakarotto57 Jan 11 '14 at 01:23
  • No problem. I'm trying to move the "More mentors announce soon" text to the center of the page. Screenshot: http://postimg.org/image/byc59dksj/ – Kakarotto57 Jan 11 '14 at 01:27
  • Thank you for your continued support AlienArrays Unfortunately the new method didn't work either. I'm starting to think it may be a fault with the original div class "fourcol". Perhaps I should create a new class? – Kakarotto57 Jan 11 '14 at 01:59
  • @Kakarotto57 Well, is it correct in the fiddle that I posted ? And just not correct on your website/server? – CRABOLO Jan 11 '14 at 02:04
  • It's correct on the Fiddle. But not on my website... Can be viewed here: www.dotforgeaccelerator.com/mentors – Kakarotto57 Jan 11 '14 at 02:32
  • @Kakarotto57 please recreate the problem in a jsfiddle – CRABOLO Jan 11 '14 at 02:33