html - CSS - 背景颜色元素问题 - 圆圈显示为椭圆形

标签 html css

我一直在努力让我的背景圆形元素变圆。

我有一个带有 X 的标签作为关闭按钮。

我将背景色放在 X 后面,所以我想在 X 后面创建一个圆圈。

我无法让圆圈变成圆圈,它显示为椭圆形。

.label {
  padding: 0 !important;
  list-style: none !important;
}

.label__choice {
  display: inline !important;
  padding: 10px;
  margin: 4px;
  color: #fff !important;
  background-color: #2ecc71;
  border: none;
  border-radius: 3px;
}

.label__choice__remove {
  width: 15px;
  height: 15px;
  margin-right: 10px;
  padding: 3px;
  color: #2ecc71 !important;
  font-weight: 900;
  background-color: #fff;
  border: none;
  border-radius: 50%;
}
<ul class="label">
  <li class="label__choice">
    <span class="label__choice__remove">×</span> Lessons
  </li>
</ul>

这是我的 fiddle :https://jsfiddle.net/mmagL4p1/1/

我做错了什么?

最佳答案

尝试添加:

display: inline-block;
  line-height: 14px;
  text-align: center;

.label__choice__remove 内

主要问题是 span 是 inline 元素,因此宽度/高度不起作用`

这是更新的片段:https://jsfiddle.net/mmagL4p1/2/

关于html - CSS - 背景颜色元素问题 - 圆圈显示为椭圆形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47431847/

相关文章:

html - 减少边框的宽度

html - 一个 div 覆盖另一个而不使用以像素为单位的高度

javascript - 轮播 - 折叠 div 中的自动高度(Glide JS)

html - Google 字体间距/渲染问题

css - 响应式电子邮件连列

css - 在异步 API 之后在 DTM 中触发的事件

html - div问题的响应高度

javascript - preventDefault 表单提交在 bootstrap popover 中不起作用

php - 处理 Exec_Shell 脚本时显示加载图像

javascript - 窗口大小调整时粘性表格标题不改变宽度