1

I centered all divs groups with div { width: 95%; margin: 0 auto; } but 1 div that has button is not centering, I tried also to place text-align: center; to various places but it not worked.

Here is the jsfiddle

EDIT: Forgot to mention I want to center for @media (max-width: 480px) only Image:

enter image description here

0

5 Answers 5

1

EDIT

It now works with 95%. SEE NEW UPDATED DEMO

Here's what I added to your media query:

.pure-controls{
margin:0 auto;
width:100%;
text-align:center;
}
.pure-controls button{
width:95%;
display:inline-block;

}

I think I figured it out. SEE DEMO

I added this to your media queries:

.pure-controls{
width:100%;
text-align:center;
}
.pure-controls button{
display:inline-block;

}
5
  • Its still not working, if you change width to 95% the button is not centered.
    – a1204773
    Commented Dec 4, 2013 at 4:56
  • that's why it has to be 100% lol didn't you want it to be 100% like in your picture?
    – JJJ
    Commented Dec 4, 2013 at 4:59
  • I don't want it to be 100, my other divs worked with 95% but the last div not working.. I want to have 2.5% space left and right.
    – a1204773
    Commented Dec 4, 2013 at 5:01
  • Well yes its working now for media (max-width: 480px) but the button is now too big at media (min-width: 480px)
    – a1204773
    Commented Dec 4, 2013 at 5:07
  • if you would've just added my snipped of code to your code it would've worked fine. I was messing with the code and I forgot to change it. But here is the updated updated super new version: jsfiddle.net/A9UNA/10
    – JJJ
    Commented Dec 4, 2013 at 5:12
0

do this

 <div class="pure-controls" style="text-align:center">

container of the button should have text-align:center

5
  • forgot to mention I want to center only for @media (max-width: 480px)
    – a1204773
    Commented Dec 4, 2013 at 4:48
  • @Loclip what do u mean by that? Commented Dec 4, 2013 at 4:51
  • If you resize window to smaller with smaller than 480px I apply different style. I want the button to be centered there.
    – a1204773
    Commented Dec 4, 2013 at 4:53
  • Try moving container of your button inside @media Commented Dec 4, 2013 at 5:01
  • let us continue this discussion in chat Commented Dec 4, 2013 at 5:05
0

You missed for pure-controls class

.pure-controls {
  text-align: center
}

Also this div is slightly positioned away from the others. Even after centering the button will be little away from center.

1
  • forgot to mention I want to center only for @media (max-width: 480px)
    – a1204773
    Commented Dec 4, 2013 at 4:49
0

make its Enclosing div's class pure-controls have this css

.pure-controls {
  text-align: center
}

Demo fiddle

1
  • forgot to mention I want to center only for @media (max-width: 480px)
    – a1204773
    Commented Dec 4, 2013 at 4:50
0

Try this css:

.pure-controls {
    margin: 1.5em 0 0 10em;
    margin-left:10%;
}

or

.pure-controls {
    margin: 1.5em 0 0 10em;
    text-align: center;
}
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.