复选框在浮动上移动:向右

时间:2013-03-21 19:51:12

标签: javascript css html5 checkbox

过去几天我一直有这个问题。我试图将我的复选框移动到窗口右侧的窗格中。但是,每当我使用浮动时:向右移动它们也会向下移动约20-30px,这意味着它们不再正确地与它们的标签对齐。

以下是我想要对齐的标签/图片/复选框的窗格代码:

<div id="leftPane" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'left'">

            <div id="sealDiv" style="padding-top:0px;vertical-align:middle;"><a href="http://google.com"><img src="images/seal.png" alt="countySeal" style="width:150px;height:150px; "/></a></div>

            <h3 style="vertical-align:middle;"><u> Live Layers </u></h3>
            <div id="layerLabels">
            <img src="images/stateParkIcon.png" alt="stateParksIcon" style="height:20px; width:20px"/> <label>State Parks <input id="stateParks" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="stateChanged()"></label>
            <br/>
            <img src="images/countyParksIcon.png" alt="countyParksIcon" style="height:20px; width:20px;"/> <label>County Parks <input id="countyParks" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="countyChanged()"></label>
            <br/>
            <img src="images/countyOpenSpaceIcon.png" alt="countyOpenSpaceIcon" style="height:20px; width:20px"/> <label>County Open Spaces <input id="countyOpenSpace" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="countyOpenChanged()"></label>
            <br/>
            <img src="images/localParksIcon.png" alt="localParksIcon" style="height:20px; width:20px"/> <label>Local Parks <input id="localParks" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="localChanged()"></label>
            <br/>
            <img src="images/golfCourse.png" alt="imgGolf" style="height:20px; width:20px"/> <label>Golf Courses <input id="golfCourses" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="golfCoursesChanged()"></label>
            <br/>
            <img src="images/beach.png" alt="imgBeach" style="height:20px; width:20px"/> <label>Beaches <input id="beaches" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="beachesChanged()"></label>
            <br/>
            <img src="images/iceRink.png" alt="imgIce" style="height:20px; width:20px"/> <label>Ice Rinks <input id="iceRinks" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="iceRinksChanged()"></label>
            <br/>
            <img src="images/swimming.png" alt="imgSwim" style="height:20px; width:20px"/> <label>Indoor Pools <input id="indoorPools" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="indoorPoolsChanged()"></label>
            <br/>
            <img src="images/campgrounds.png" alt="imgCamp" style="height:20px; width:20px"/> <label>Campgrounds <input id="campgrounds" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="campgroundsChanged()"></label>
            <br/>
            <img src="images/boatLaunches.png" alt="imgBoat" style="height:20px; width:20px"/> <label>Boat Launches <input id="boatLaunches" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="boatLaunchesChanged()"></label>
            <br/>
            <img src="images/marinas.png" alt="imgMarinas" style="height:20px; width:20px"/> <label>Marinas <input id="marinas" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="marinasChanged()"></label>
            <br/>
            <img src="images/playgrounds.png" alt="imgPlaygronds" style="height:20px; width:20px"/> <label>Playgrounds <input id="playgrounds" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="playgroundsChanged()"></label>
            <br/>
            <img src="images/bikepath.png" alt="imgBike" style="height:20px; width:20px"/> <label>Bike Paths <input id="bikePaths" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="bikePathsChanged()"></label>
            <br/>
            <img src="images/boardwalksIcon.png" alt="boardwalkIcon" style="height:20px; width:20px"/> <label>Boardwalks <input id="boardwalks" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="boardwalksChanged()"></label>
            <br/>
            <img src="images/hikingIcon.png" alt="hikingIcon" style="height:20px; width:20px"/> <label>Hiking Trails <input id="hikingTrails" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="hikingTrailsChanged()"></label>
            <br/>
            <img src="images/crosswalksIcon.png" alt="crosswalksIcon" style="height:20px; width:20px"/> <label>Crosswalks <input id="crosswalks" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="crosswalksChanged()"></label>
            <br/>
            <img src="images/sidewalksIcon.png" alt="sidewalkIcon" style="height:20px; width:20px;"/> <label>Sidewalks <input id="sidewalks" class="lyrCB" data-dojo-type="dijit.form.CheckBox" onChange="sidewalksChanged()"></label>
            </div>
        </div>

是否有一个“快速解决方案”,无论是CSS还是Javasript还是我创建了窗格,需要重做才能正常工作?

谢谢!

1 个答案:

答案 0 :(得分:0)

这里有一些选项,但基本上它被其他没有浮动的元素推倒。

  1. 浮动其他元素。

  2. 将复选框放在HTML中(图像和标签之前)。

  3. 改为使用绝对定位。