我有以下代码用于切换开关。我想要做的就是在这些开关的左边有一些文字,但无论我做什么,它都会打破并弄乱开关。任何帮助,将不胜感激。
<section id="middle">
<h2>Heading</h2>
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch4" checked>
<label class="onoffswitch-label" for="myonoffswitch4">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch5" checked>
<label class="onoffswitch-label" for="myonoffswitch5">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
</section>
&#13;
val query = reference.child("users").orderByChild("score").limitToFirst(10)
query.addValueEventListener(object : ValueEventListener {
override fun onCancelled(p0: DatabaseError) {}
override fun onDataChange(dataSnapshot: DataSnapshot) {
dataSnapshot.children.forEach {
val score: String = it.child(Constants.scoreKey).value as String
Log.i(TAG,"score:"+score)
}
}
})
&#13;
不确定为什么它不会让我只是向左浮动文字。
答案 0 :(得分:0)
使用表格标签进行整理。
if let temperature = Double(temperatureValue) {
// compare "temperature" to other Double values
}
答案 1 :(得分:0)
好吧,你必须为每个开关创建一个swicth容器,并创建另一个孩子,你在
标签内或你想要它的内容。你需要把
display:inline-block;
在开关和文本容器中。看看我编辑.onoffswitch类并添加另一个名为.switchtext
的其他类这是我的样本
.onoffswitch {
position: relative; width: 90px;
display: inline-block;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
border: 2px solid #999999; border-radius: 20px;
}
.onoffswitch-inner {
display: block; width: 200%; margin-left: -100%;
transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
display: block; float: left; width: 50%; height: 30px; padding: 0; line-height: 30px;
font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
box-sizing: border-box;
}
.onoffswitch-inner:before {
content: "ON";
padding-left: 10px;
background-color: #34A7C1; color: #FFFFFF;
}
.onoffswitch-inner:after {
content: "OFF";
padding-right: 10px;
background-color: #EEEEEE; color: #999999;
text-align: right;
}
.onoffswitch-switch {
display: block; width: 18px; margin: 6px;
background: #FFFFFF;
position: absolute; top: 0; bottom: 0;
right: 56px;
border: 2px solid #999999; border-radius: 20px;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px;
}
.switchtext{
display: inline-block;
}
&#13;
<section id="middle">
<h2>Heading</h2>
<div class="swicth-container">
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch4" checked>
<label class="onoffswitch-label" for="myonoffswitch4">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
<div class="switchtext">
<p>
TEXT
</p>
</div>
</div>
<div class="swicth-container">
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch5" checked>
<label class="onoffswitch-label" for="myonoffswitch5">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
<div class="switchtext">
<p>
SOME TEXT
</p>
</div>
</div>
</section>
&#13;