html - 具有边框半径的CSS中的完美圆不起作用

标签 html css

圆往往是椭圆形的,我想要的是正圆。 border-radius 100% 不起作用我想知道为什么..

http://jsfiddle.net/8gD2m/1/

.badge {
    display: inline-block;
    min-width: 10px;
    padding: 3px 7px;
    font-size: 12px;
    font-weight: lighter !important;
    line-height: 1;
    color: #fff !important;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    background-color: #d73d33;
    border-radius: 50px;
    position: relative;
    top: -3px;
}

最佳答案

这是一个有一些变化的 JSfiddle:

JSFiddle for round badge

主要变化是:

padding: 0px;
width: 50px;
height: 50px;
line-height: 50px;

行高等于容器高度将使文本垂直居中。这仅在文本适合单行时才有效。

编辑:(从 JSFiddle 复制代码)

.badge {
    display: inline-block;
   
    padding: 0;
    width: 50px;
    height: 50px;    
    line-height: 50px;
    
    font-size: 12px;
    font-weight: lighter !important;
    color: #fff !important;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    background-color: #d73d33;
    border-radius:50px;
    position: relative;
    top: -3px;
}
<span class="badge badge-success">8</span>

关于html - 具有边框半径的CSS中的完美圆不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21717149/

相关文章:

html - 如果div位于屏幕中心,如何在底部左右显示文本

html - 优化多个 HTML5 视频

css - 为什么我的图像行没有跨越完整的 col-md-10 宽度?

javascript - 如何在 CSS 圆内显示全尺寸图像?

html - hover 和 focus 伪类 Action

html - 带有叠加文本的响应图像保持在同一位置

c# - 如何为 <% %> 之间的文本添加颜色样式

javascript - 使用内联 CSS 在 React 元素中以相反的顺序显示 <li>

javascript - 悬停 div svg 路径颜色更改

CSS3 馅饼不工作