Text within circle div. Div size adjusted to content

前端 未结 5 1128
庸人自扰
庸人自扰 2020-12-19 04:52

I want to create a circle div with text in (not only one line). This is the kind behavior I want:

\"http://i.img

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-19 05:34

    Hope this helps you in any way, but be aware that it does not guarantee that all the content will be inside the circle!

    I would create a div and a span to the content:

    And then I would apply a CSS to border the div with a radius that would make it like a circle. Vertical alignmento of the span should place it in the middle.

    Content goes here

    And the CSS:

    div{
    border-style:solid;
    border-color: black;
    width: 300px;
    height:300px;
    text-align: center;
    border-radius: 300px;
    vertical-align:middle;
    display:table;
    padding: 5px;
    }
    
    span{
    display:table-cell;
    vertical-align:middle;
    }
    

    You may test it here: http://jsfiddle.net/S3cNW/

提交回复
热议问题