How do I create a circle or square with just CSS - with a hollow center?

后端 未结 8 2503
南旧
南旧 2020-12-13 08:47

It should just basically be an outline of the square or circle - that I can style accordingly (i.e. change the color to whatever I want, change the thickness of the border,

相关标签:
8条回答
  • 2020-12-13 09:25

    If you want your div to keep it's circular shape even if you change its width/height (using js for instance) set the radius to 50%. Example: css:

    .circle {
        border-radius: 50%/50%; 
        width: 50px;
        height: 50px;
        background: black;
    }
    

    html:

    <div class="circle"></div>
    
    0 讨论(0)
  • 2020-12-13 09:30

    i don't know of a simple css(2.1 standard)-only solution for circles, but for squares you can do easily:

    .squared {
        border: 2x solid black;
    }
    

    then, use the following html code:

    <img src="…" alt="an image " class="squared" />
    
    0 讨论(0)
提交回复
热议问题