html - Show label and sliding checkbox on same line -
in html page, trying align label , sliding checkbox on same line. code given below (the sliding checkbox code taken post here).
.ondisplay { display: inline-block; } /* slide 3 */ .slidethree { width: 80px; height: 26px; background: #333; margin: 10px auto; -webkit-border-radius: 50px; -moz-border-radius: 50px; border-radius: 50px; position: relative; -webkit-box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.5), 0px 1px 0px rgba(255, 255, 255, 0.2); -moz-box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.5), 0px 1px 0px rgba(255, 255, 255, 0.2); box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.5), 0px 1px 0px rgba(255, 255, 255, 0.2); } .slidethree:after { content: 'off'; font: 12px/26px arial, sans-serif; color: #000; position: absolute; right: 10px; z-index: 0; font-weight: bold; text-shadow: 1px 1px 0px rgba(255, 255, 255, .15); } .slidethree:before { content: 'on'; font: 12px/26px arial, sans-serif; color: #00bf00; position: absolute; left: 10px; z-index: 0; font-weight: bold; } .slidethree label { display: block; width: 34px; height: 20px; -webkit-border-radius: 50px; -moz-border-radius: 50px; border-radius: 50px; -webkit-transition: .4s ease; -moz-transition: .4s ease; -o-transition: .4s ease; -ms-transition: .4s ease; transition: .4s ease; cursor: pointer; position: absolute; top: 3px; left: 3px; z-index: 1; -webkit-box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.3); -moz-box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.3); box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.3); background: #fcfff4; background: -webkit-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); background: -moz-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); background: -o-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); background: -ms-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); background: linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); filter: progid: dximagetransform.microsoft.gradient(startcolorstr='#fcfff4', endcolorstr='#b3bead', gradienttype=0); } .slidethree input[type=checkbox]:checked + label { left: 43px; } input[type=checkbox] { visibility: hidden; } }
<div class="ondisplay"> <div><strong>test: </strong> </div> <div class="slidethree"> <input type="checkbox" value="none" id="slidethree" name="check" checked/> <label for="slidethree"></label> </div> </div>
with these, label "test" , slider appearing 1 below other left-aligned. need them appear on same line, first label slider. tried display: inline
didn't work. still kind of new css. can please?
edit: fiddle referred - http://jsfiddle.net/cxn3v/
add following css rule.
.ondisplay > div { display: inline-block; }
.ondisplay { display: inline-block; } .ondisplay > div { display: inline-block; } /* slide 3 */ .slidethree { width: 80px; height: 26px; background: #333; margin: 10px auto; -webkit-border-radius: 50px; -moz-border-radius: 50px; border-radius: 50px; position: relative; -webkit-box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.5), 0px 1px 0px rgba(255, 255, 255, 0.2); -moz-box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.5), 0px 1px 0px rgba(255, 255, 255, 0.2); box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.5), 0px 1px 0px rgba(255, 255, 255, 0.2); } .slidethree:after { content: 'off'; font: 12px/26px arial, sans-serif; color: #000; position: absolute; right: 10px; z-index: 0; font-weight: bold; text-shadow: 1px 1px 0px rgba(255, 255, 255, .15); } .slidethree:before { content: 'on'; font: 12px/26px arial, sans-serif; color: #00bf00; position: absolute; left: 10px; z-index: 0; font-weight: bold; } .slidethree label { display: block; width: 34px; height: 20px; -webkit-border-radius: 50px; -moz-border-radius: 50px; border-radius: 50px; -webkit-transition: .4s ease; -moz-transition: .4s ease; -o-transition: .4s ease; -ms-transition: .4s ease; transition: .4s ease; cursor: pointer; position: absolute; top: 3px; left: 3px; z-index: 1; -webkit-box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.3); -moz-box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.3); box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.3); background: #fcfff4; background: -webkit-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); background: -moz-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); background: -o-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); background: -ms-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); background: linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); filter: progid: dximagetransform.microsoft.gradient(startcolorstr='#fcfff4', endcolorstr='#b3bead', gradienttype=0); } .slidethree input[type=checkbox]:checked + label { left: 43px; } input[type=checkbox] { visibility: hidden; } }
<div class="ondisplay"> <div><strong>test: </strong> </div> <div class="slidethree"> <input type="checkbox" value="none" id="slidethree" name="check" checked/> <label for="slidethree"></label> </div> </div>
Comments
Post a Comment