2016-09-29 18 views
0

我遵循在ReactJS中创建圆形图像的标准过程。边框半径:在控制台中划出圆形图像的50%

.about-profile { 
    display: block; 
    width: 260px; 
    height: 260px; 
    border-radius: 50%; 
} 

<img className="about-profile" src="./images/profile.jpg"/> 

enter image description here

为什么border-radius: 50%没有在这种情况下应用?

+0

交叉出文本意味着它覆盖其他地方!你确定你的元素没有应用其他的CSS吗?另外'边界:1px纯红色';'和'border-left:2px纯蓝色;'会划掉'border:'规则 – Justinas

回答

2

这就是CSS中的级联。其他一些规则是覆盖你的边界半径。

欲了解更多详情,请参阅https://www.w3.org/TR/2011/REC-CSS2-20110607/cascade.html#cascade

你可以做的是要么改变.about-profile更“具体”,或使用!important覆盖其他规则。我建议前者。

+0

谢谢。我检查了我的其他规则,没有看到任何可能压倒它的东西。但那是一个正确的答案!将在6分钟内upvote :) – patrickhuang94

0

您可以使用此:

border-radius: 50%!important; 
0

一些样式替代这个代码,以便使用重要

.about-profile { 
    display: block; 
    width: 260px; 
    height: 260px; 
    border-radius: 50%; 
}