How can I center align a div without knowing the width?

后端 未结 9 1480
感情败类
感情败类 2021-02-09 18:45

I\'ve looked this up and the outlook seems bleak. I\'m not interested in using a table. I have 6 or so \'a element\' inline-blocks that make up a menu. It\'s slick, except all t

9条回答
  •  说谎
    说谎 (楼主)
    2021-02-09 19:08

    the div element will take all the width space of the container element if it isn't set a width value.

    So if you want to center a div you must set a width...

    A solution to your problem (if I have understand it) can be:

    [... yours content ...]

    where your div has became a span and a new div puts the span in the center. Hope this can help you! Bye, Alberto

提交回复
热议问题