简体   繁体   English

如何在反应图标周围添加圆形背景?

[英]How can i add a circular backgrounds around a react icon?

How can I add circular backgrounds around icons?如何在图标周围添加圆形背景? I currently have an icon from react-icons and would like to add a circle around it.我目前有一个来自 react-icons 的图标,想在它周围添加一个圆圈。 But so far some of my methods have not worked.但到目前为止,我的一些方法还没有奏效。 Any input is valued.任何输入都是有价值的。

below is the approach and thank you.以下是方法,谢谢。

import { RiRocketLine } from 'react-icons/ri'
....
<div id='icons' className='icon'>
   <RiRocketLine style={{ color: 'red' }} size="30px" />
</div>

You have to use border-radius and border你必须使用border-radiusborder

I used plain html, but the answer will not differ for react我使用普通的 html,但反应的答案不会有所不同

 .icon { border-radius: 50%; border: 2px solid red; padding: 5px; font-size: 30px; }
 <span class="icon"></span>

Suggestion: You can change the div border-radius by 50% and adjust the position of your icon, I hope it will work for you.建议:你可以把div border-radius改50%,调整图标的position,希望对你有用。

#icons{
    background: transparent;
    border-radius: 50%;
    width: 100px;
    height: 100px;
}

import { RiRocketLine } from 'react-icons/ri'
....
<div id='icons' className='icon'>
   <RiRocketLine style={{ color: 'red' }} size="30px" />
</div>

you can check this StackOverflow link你可以查看这个StackOverflow 链接

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

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