How to make a circle around content using CSS?

前端 未结 6 1531
梦毁少年i
梦毁少年i 2020-11-28 23:39

Like this

\"circle

With only this code

1
         


        
6条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 00:05

    You have many answers now but I try tell you the basics.

    First element is inline element so giving it margin from top we need to convert it to block element. I converted to inline-block because its close to inline and have features of block elements.

    Second, you need to giving padding right and left more than top and bottom because numerals itself extend from top to bottom so it gets reasonable height BUT as we want to make the span ROUND so we give them padding more on left and right to make room for BORDER RADIUS.

    Third, you set border-radius which should be more than PADDING + width of content itself so around 27px you will get required roundness but for safely covering all numerals you can set it to some higher value.

    Practical Example.

提交回复
热议问题