我正在使用jquery来设置复选框的样式。我已经成功地做到了这一点,但现在我无法获得复选框和标签在同一行。
以下是主要代码:
<ul class="facebook-friends">
@foreach ($friends as $friend)
<li>
<div class="facebook_friend">
<input tabindex="1" type="checkbox" name="friend" id="{{$friend}}" value="{{$friend}}">
<label for="{{$friend}}" style="display:block;">
<span class="icon"><a href="http://www.facebook.com/{{ $friend }}"><img src="https://graph.facebook.com/{{ $friend }}/picture" alt="" height="40" width="40"></a></span>
</label>
</div>
</li>
@endforeach
</ul>CSS:
.facebook_friend {
width:150px;
}
.icon {
width:45px;
}
ul.facebook-friends {
margin:0;
padding:0;
border:0;
overflow:hidden;
*zoom:1;
width:500px;
font-family:'proxima-nova';
font-size:12px;
color:#999
}
ul.facebook-friends li {
list-style-image:none;
list-style-type:none;
margin-left:0;
white-space:normal;
display:inline;
float:left;
padding-left:0px;
margin: 5px;
}iCheck框呈现如下所示:
<div class="icheckbox_square-blue" style="position: relative;">
<input tabindex="1" type="checkbox" name="friend" id="3607" value="3607" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background-color: rgb(255, 255, 255); border: 0px; opacity: 0; background-position: initial initial; background-repeat: initial initial;">
<ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background-color: rgb(255, 255, 255); border: 0px; opacity: 0; background-position: initial initial; background-repeat: initial initial;"></ins>
</div>用于复选框标签的图像显示在复选框下的行上。你看到什么会导致这种情况的吗?我想让他们排队。我用的是Laravel 4。
发布于 2013-10-08 14:58:07
把你的input/checkbox移到标签里,就像
<ul>
@foreach ($friends as $friend)
<li>
<div class="facebook_friend">
<label for="{{$friend}}" style="display:block;">
<input tabindex="1" type="checkbox" name="friend" id="{{$friend}}" value="{{$friend}}">
<span class="icon">
<a href="http://www.facebook.com/{{ $friend }}">
<img src="https://graph.facebook.com/{{ $friend }}/picture" alt="" height="40" width="40">
</a>
</span>
</label>
</div>
</li>
@endforeach
</ul>。
发布于 2013-10-08 07:07:04
你可能漏掉了一个小错误,
我创建了一个示例fiddle来解释这个证据,
只需像这样修改你的代码。
<ul>
@foreach ($friends as $friend)
<li>
<div class="facebook_friend">
<input tabindex="1" type="checkbox" name="friend" id="{{$friend}}" value="{{$friend}}">
<label for="{{$friend}}"> /* Removed display:block here */
<span class="icon"><a href="http://www.facebook.com/{{ $friend }}"><img src="https://graph.facebook.com/{{ $friend }}/picture" alt="" height="40" width="40"></a></span>
</label>
</div>
</li>
@endforeach
</ul> 我已经把style="display:block"从label标签上去掉了,这真的很管用,
检查小提琴是否有小样本,
编辑:由于这些样式表无法工作,因此更改样式表可能会添加更多的样式,
ul.facebook-friends li {
list-style-image:none;
list-style-type:none;
white-space:normal;
display:inline;
padding-left:0px; /* this was lfet you need to correct it*/
margin: 5px;
margin-left:0; /* this was over ridden by the 5px as it was specified after */
position:relative;
}编辑2:更新的Fiddle
我已经更新了小提琴来验证您的代码fiddle2,但是这里也很好。!!
请提供您的网页的现场链接,以获得进一步帮助,谢谢
发布于 2016-03-17 12:22:02
我已经解决了一个类似的问题,我也希望复选框内联,但我需要右边的文本能够跨越2行而不低于复选框。
似乎对齐复选框的诀窍是在它周围有另一个容器(在我的例子中是<i>),我将其定位为绝对,更改默认的复选框容器位置将使可单击区域变得混乱。
<div class="rcb-recent">
<div class="rcb-recent-items">
<!-- ROW -->
<div class="rcb-recent-item">
<i>
<input type="checkbox" class="recent-cb" checked="checked" />
</i>
<span>
<a href="#">1-year Master in International Cooperation & Development</a>
</span>
</div>
<!-- ROW -->
<div class="rcb-recent-item">
<i>
<input type="checkbox" class="recent-cb" checked="checked" />
</i>
<span>
<a href="#">1-year Master in International Cooperation & Development</a>
</span>
</div>
</div>
</div>CSS
.rcb-recent {
width: 200px
}
.rcb-recent-item {
position: relative;
margin-bottom: 10px
}
.rcb-recent-item i {
position: absolute;
left: 0;
top: 0;
}
.rcb-recent-item span {
display: block;
margin-left: 30px;
}https://stackoverflow.com/questions/19191326
复制相似问题