How do I center floated elements?

前端 未结 12 2591
谎友^
谎友^ 2020-11-22 00:16

I\'m implementing pagination, and it needs to be centered. The problem is that the links need to be displayed as block, so they need to be floated. But then, text-alig

12条回答
  •  臣服心动
    2020-11-22 01:00

    Add this to you styling

    position:relative;
    float: left;
    left: calc(50% - *half your container length here);
    

    *If your container width is 50px put 25px, if it is 10em put 5em.

提交回复
热议问题