简体   繁体   English

用于跟踪栏开始和结束的HTML CSS上标签

[英]HTML CSS upper label for start and end of trackbar

I need to display upper labels for start and end sides of trackbar (input type="range"). 我需要为轨迹栏的起点和终点显示上标签(输入类型=“范围”)。 Should be done as in the picture: 应如图所示:

两个轨道栏

Labels are highlighted in red. 标签以红色突出显示。 Here is a fragment of my HTML code: 这是我的HTML代码的一个片段:

<div class="trackbar">
    <span class="bound_label">20 000</span>
    <input type="range" />
    <span class="bound_label">3 000 000</span>
</div>

What styles should be for the class 'bound_label' to display it correctly (as in the picture)? 类'bound_label'应该使用哪些样式才能正确显示它(如图所示)? Thanks! 谢谢!

UPDATE Thanks all for answers. 更新感谢大家的答案。 But there is one important point! 但有一点很重要! The center of upper label must be aligned by bottom of trackbar (as in the picture, align by green line)! 上部标签的中心必须与轨迹栏的底部对齐(如图所示,以绿线对齐)! How I can solve it?? 我怎么解决? 对齐线

A simple way is to move your labels at top: 一种简单的方法是将标签移到顶部:

.trackbar .bound_label {
  float: right;
}
.trackbar .bound_label:first-of-type {
  float: left;
}
.trackbar > input {
  display: block;
  width: 100%;
}

plunker: Plunker example plunker: Plunker例子

HTML: HTML:

<div class="trackbar 1">
    <span class="bound_label left">20 000</span>
    <span class="bound_label right">3 000 000</span>
    <input type="range">
</div>
<div class="trackbar 2">
    <span class="bound_label left">1</span>
    <span class="bound_label right">60</span>
    <input type="range">
</div>

CSS CSS

input[type="range"] {
    width:100%;
}
input[type="range"]::-moz-range-progress {
    background-color: red; 
}

input[type="range"]::-moz-range-track {  
    background-color: grey;
}

.trackbar .bound_label.left {
    float:left;
}
.trackbar .bound_label.right {
    float:right;
}

JSFiddle demo JSFiddle演示

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

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