0

I have a webpage and I'm using Jquery mobile.

I have an image and un text and I would like to center the content in my page horizontaly and verticaly, and when I modify the width of the window, the content should adapt.

Here is an example :

In the example, the content adapt correctly, but it's not centered. if I set the style of my content div to :

style="position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: auto;width: 500px;"

To my div, the content is centered but no longer adapt...

Can you update my jsfiddle to do what I need ?

user3544117
  • 587
  • 4
  • 9
  • 25

3 Answers3

1

You can work with display: table; on the outer and display:table-cell on the inner container to center stuff vertically. Check this out:

http://jsfiddle.net/NrCGb/578/

EDIT Max width 500px for content:

http://jsfiddle.net/NrCGb/585/

Charles Ingalls
  • 4,521
  • 5
  • 25
  • 33
0

(example: 502 Bad Gateway) jQuery Mobile is not good for customization. Use it as it is or don't use it at all. After two projects with it, I find no benefit, just headache. Try with !important

0

This should work

#content {
    margin: auto;
    position: absolute;
    top: 50%;
    margin-top: -250px;
    left: 0;
    right: 0;
    text-align: center;
    height: 500px;
}

http://jsfiddle.net/wesleysmits/NrCGb/581/

This article could prove useful to you as well http://www.smashingmagazine.com/2013/08/09/absolute-horizontal-vertical-centering-css/

This stackoverflow thread might also help you. Center a DIV horizontally and vertically

Community
  • 1
  • 1
Wesley Smits
  • 1,314
  • 6
  • 23
  • 37