我想在我的網頁上添加一個HTML開關,但問題是 - 我想看看我的切換狀態,所以訪問者不能改變它,但只能看到。對於訪問者不活動的HTML開關
我有這樣的:
.onoffswitch {
position: relative; width: 122px;
-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 #FFFFFF; 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: 26px; padding: 0; line-height: 26px;
font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
box-sizing: border-box;
}
.onoffswitch-inner:before {
content: "otevreno";
padding-left: 12px;
background-color: #34C258; color: #000000;
}
.onoffswitch-inner:after {
content: "zavreno";
padding-right: 12px;
background-color: #D16464; color: #000000;
text-align: right;
}
.onoffswitch-switch {
display: block; width: 5px; margin: 10.5px;
background: #FFFFFF;
position: absolute; top: 0; bottom: 0;
right: 92px;
border: 2px solid #FFFFFF; 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;
}
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch">
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
我的問題是:如何使切換不活動的遊客,誰能夠只看到切換的狀態(「otevreno」或「zavreno」),只有我可以編輯切換器的狀態?
謝謝。
我相信你應該能夠將'readonly'屬性添加到輸入中?只是'readonly',而不'readonly =「etc」'。 – Katana314