html - 创建产品分数值

标签 html css

我是 css 和 html 的新手,我想 cr8 像这样的产品框值

http://i.imgur.com/kMogtMz.png

我试过这些但没有得到任何结果。
我希望 .fill 类可以动态修改。
任何人都可以帮助我吗?

.box {
  width: 250px;
  height: 30px;
  background: grey;
  color: white
}
.box .fill {
  float: left;
  width: 78%;
  background: orange;
  height: 100%;
}
.box .empty {
  position: absolute;
  white-space: nowrap;
  right: 10px
}
.box .fill-badge {
  position: absolute;
  padding-left: 10px;
  line-height: 30px
}
.box .empty-badge {
  padding-right: 10px;
  line-height: 30px;

}
<div class="box">
  <div class="fill"><div class="fill-badge">Radeon 7870</div></div>
  <div class="empty"><div class="empty-badge">125.6 GB/S</div></div>
</div>

最佳答案

您只需要查看您的绝对相对 定位。确保所有绝对定位的元素都在以相对定义为位置的元素内。所以在这种情况下,您只需要将 position: relative; 添加到 .box 即可。

    .box {
      width: 250px;
      height: 30px;
      background: grey;
      color: white;
      position: relative;
    }

    .box .fill {
      float: left;
      background: orange;
      height: 100%;
    }

    .box .empty {
      float: right;
      white-space: nowrap;
      right: 10px
    }

    .box .fill-badge {
      position: absolute;
      left: 0;
      padding-left: 10px;
      line-height: 30px
    }

    .box .empty-badge {
      position: absolute;
      right: 0;
      padding-right: 10px;
      line-height: 30px;
    }
<div class="box">
  <div class="fill" style="width:60%;">
    <div class="fill-badge">Radeon 7870</div>
  </div>
  <div class="empty">
    <div class="empty-badge">125.6 GB/S</div>
  </div>
</div>

编辑以显示内联样式。

关于html - 创建产品分数值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26545045/

相关文章:

c# - 内联 block 似乎不起作用

javascript - 如何根据下拉选项列表中的选定值过滤 div?

html - 制作响应式网站和标题图片无法正确响应

javascript - 如何使用 jQuery 将 div css 的可见性更改为可见

javascript - 网页中元素图像的动态变化

javascript - 动态添加输入元素以形成并将值存储在数据库中

html - CSS/Javascript 如何像在 IE7+ 中那样在 Firefox 中制作这个背景位置影片?

jquery - 用jquery添加类

html - CSS 定位问题 : invalid property value

jquery - 如何在特定的 div 中显示固定的隐藏菜单?