Html滑块,每侧有文字

时间:2016-05-15 14:27:14

标签: html css

我对html和css有疑问。我试图用文本制作一个div --- slider - text。这是它应该如何看的照片。

Result

这是我目前的情况。

Situation

我希望有人可以帮助我将这些元素放在一行。



.information_seperator {
  height: 4vh;
  background-color: #ffffff;
}
.divider {
  width: 50vw;
  background-color: #ffc539;
  margin-top: 0px;
  margin-bottom: 0px;
}
.divider:after {
  content: " ";
  width: 5px;
  height: 5px;
  position: relative;
  top: 0;
  right: 10px;
  background-color: #ffc539;
}

<div class="information_seperator">
  <!--<div class="row">-->
  <span class="text_info">AMS</span>
  <hr class="divider">
  <!--<input data-provide="slider" id="ex1" data-slider-id='ex1Slider' type="text" data-slider-min="0" data-slider-max="20" data-slider-step="1" data-slider-value="20"/>-->
  <!--<span style="color: #ffc539">&#9679;</span>-->
  <span>JFC</span>
  <!--</div>-->
</div>
&#13;
&#13;
&#13;

3 个答案:

答案 0 :(得分:0)

我认为你需要阅读

 display: inline-block

答案 1 :(得分:0)

要将元素彼此对齐,请使用:display:inline;

示例:

&#13;
&#13;
span,
div {
  display: inline;
}
//Slider
input[type=range] {
  -webkit-appearance: none;
  margin: 18px 0;
  width: 100%;
}
input[type=range]:focus {
  outline: none;
}
input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 8.4px;
  cursor: pointer;
  animate: 0.2s;
  box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
  background: #3071a9;
  border-radius: 1.3px;
  border: 0.2px solid #010101;
}
input[type=range]::-webkit-slider-thumb {
  box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
  border: 1px solid #000000;
  height: 36px;
  width: 16px;
  border-radius: 3px;
  background: #ffffff;
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -14px;
}
input[type=range]:focus::-webkit-slider-runnable-track {
  background: #367ebd;
}
input[type=range]::-moz-range-track {
  width: 100%;
  height: 8.4px;
  cursor: pointer;
  animate: 0.2s;
  box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
  background: #3071a9;
  border-radius: 1.3px;
  border: 0.2px solid #010101;
}
input[type=range]::-moz-range-thumb {
  box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
  border: 1px solid #000000;
  height: 36px;
  width: 16px;
  border-radius: 3px;
  background: #ffffff;
  cursor: pointer;
}
input[type=range]::-ms-track {
  width: 100%;
  height: 8.4px;
  cursor: pointer;
  animate: 0.2s;
  background: transparent;
  border-color: transparent;
  border-width: 16px 0;
  color: transparent;
}
input[type=range]::-ms-fill-lower {
  background: #2a6495;
  border: 0.2px solid #010101;
  border-radius: 2.6px;
  box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
}
input[type=range]::-ms-fill-upper {
  background: #3071a9;
  border: 0.2px solid #010101;
  border-radius: 2.6px;
  box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
}
input[type=range]::-ms-thumb {
  box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
  border: 1px solid #000000;
  height: 36px;
  width: 16px;
  border-radius: 3px;
  background: #ffffff;
  cursor: pointer;
}
input[type=range]:focus::-ms-fill-lower {
  background: #3071a9;
}
input[type=range]:focus::-ms-fill-upper {
  background: #367ebd;
}
&#13;
<span>text</span>
<div>
  <input type=range />
</div>
<span>text</span>
&#13;
&#13;
&#13;

答案 2 :(得分:0)

您可以使用FlexboxJQuery UI

执行此操作

$('.circle').draggable({
  axis: "x",
  containment: ".line"
});
.slider {
  display: flex;
  align-items: center;
}
.line {
  flex: 1;
  height: 4px;
  background: #FBC538;
  position: relative;
  margin: 0 10px;
}
.circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #FBC538;
  position: absolute;
  left: 0;
  top: -8px;
}
span:not(.circle) {
  font-size: 30px;
  font-weight: bold;
  font-family: Sans-serif;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<div class="slider">
  <span>AMS</span>
  <div class="line"><span class="circle"></span></div>
  <span>JFC</span>
</div>