Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS How do you center a dynamic content in css?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #45480
    devil2x2
    Member

    Hi, how do you center a dynamic div? If you know that the cotent inside it may grow in future , you cannot give it a fixed width and do margin:0 auto; . Sometime text-align: Center; works but not always. Like here is a situation, how do I center my pagination at the bottom? This is the LINK to my website.
    Please help.
    Thanks

    #138479
    Paulie_D
    Member

    You can center it by giving it a max-width and the margin:auto

    #138482
    devil2x2
    Member

    Thanks Paulie, can you explain a little more please. I didn’t get it , Like in my case what max-width shall I give to center the pagination when I know that the pagitation may go full wide?

    #138484
    Paulie_D
    Member

    Margin:auto only works with a fixed width or a max-width.

    I don’t know the full CSS or HTML structure of your page or any sub elements of the div (or components of the pagination) but try experimenting.

    #138485
    Paulie_D
    Member

    However, what you are actually trying to do is have the span and `a` center inside the div (which would be also be centered)

    What you might try is using `inline-block` on the span and anchors and setting text-align center on the div.

    Sort of like this…http://codepen.io/Paulie-D/pen/liuep

    #138487
    devil2x2
    Member

    That’s exactly I just did, thanks Paulie
    I think it always do the job.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘CSS’ is closed to new topics and replies.