我无法从 w3c 教程中获得一个切换开关以与旁边的一些文本对齐。
这是教程https://www.w3schools.com/howto/howto_css_switch.asp
这是我的代码:
<div class="sliderWrapper">
<div><?php echo __('Postal Address');?> </div>
<label class="switch">
<input type="checkbox" name="data[SplashPage][firstname]">
<span class="slider"></span>
</label>
</div>
<div class="sliderWrapper">
<div><?php echo __('Postal Address');?> </div>
<label class="switch">
<input type="checkbox" name="data[SplashPage][lastname]">
<span class="slider"></span>
</label>
</div>
.sliderWrapper{display: inline-block;margin:24px 24px 24px 24px;}
.sliderWrapper div{display: inline-block;line-height:60px;}
.switch {
position: relative;
display: inline-block;
padding:0px;
width: 54px;
height: 28px;
}
/* Hide default HTML checkbox */
.switch input {display:none;}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #d7d7d7;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 1px;
bottom: 1px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {background-color: #1fb5ad;}
input:focus + .slider {box-shadow: 0 0 1px #1fb5ad;}
input:checked + .slider:before {-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);transform: translateX(26px);}
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我使文本与开关垂直对齐-现在我的头一直在桌子上敲打:-(
jsfiddle: https://jsfiddle.net/vfjgtaoh/
添加行:
vertical-align: middle;
Run Code Online (Sandbox Code Playgroud)
到您的开关类,这将垂直对齐内容
小提琴:https : //jsfiddle.net/tzv75zvk/
| 归档时间: |
|
| 查看次数: |
4556 次 |
| 最近记录: |