简体   繁体   English

如何在字母周围画一个圆圈?

[英]How to make a circle around a letter?

I need to make a small circle background behind the letter "A".我需要在字母“A”后面做一个小圆圈背景。 What CSS would make this effect?什么 CSS 会产生这种效果?

See example:参见示例:

例子

With CSS? 用CSS? Something like this? 像这样的东西? http://jsfiddle.net/eLhqswyd/ http://jsfiddle.net/eLhqswyd/

<span class="i-circle">i</span>

.i-circle {
    background: #ff0000;
    color: #fff;
    padding: 5px 20px;
    border-radius: 50%;
    font-size: 35px;
}

Although this has been answered years ago, still:尽管这已在多年前得到回答,但仍然:

To make a circle around the text you can use padding like the previous answer.要在文本周围画一个圆圈,您可以像上一个答案一样使用填充。

 span{ background: red; padding: .5rem.85rem; border-radius: 50%; }
 <span>i</span><span>m</span>

But as you can see, it won't circle all the letters (m) .但如您所见,它不会圈出所有字母(m) To make any letter have a circle background, you can use fixed height and width.要使任何字母具有圆形背景,您可以使用固定的高度和宽度。 And then use flexbox/grid/absolute-position to center the text, like this:然后使用 flexbox/grid/absolute-position 将文本居中,如下所示:

 span{ width: 40px; height: 40px; display: inline-flex; /* you can also use 'grid' or just 'flex'*/ justify-content: center; align-items: center; background: red; border-radius: 50%; }
 <span>i</span><span>m</span><span>A</span>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM