现在,我正在尝试在list-group-item中插入一个图标或按钮。我想要的是,当用户单击列表-组-项中的任何位置时,他们被链接到某个页面,但当他们单击标志符号或按钮时,他们链接到另一个页面。我尝试这样做的原因是,它总是将图标或按钮放在列表分组项目框之外。为什么会这样呢?我该如何解决这个问题呢?
非常感谢。
代码:
<div class="list-group">
<a href="my_django_url" class="list-group-item">
<a href="another_django_url"><span class="glyphicon some-glyphicon"></span></a>
</a>
发布于 2014-11-25 18:22:00
这就是了:
<div class="list-group">
<li class="list-group-item">
<a href="my_django_url">
first link
</a>
<a href="another_django_url" class="icon">
<span class="glyphicon glyphicon glyphicon-search"></span>
</a>
</li>
</div>
.icon {
float: right;
}小提琴:http://jsfiddle.net/9r14uuLw/
发布于 2015-04-18 05:58:36
请原谅我的简短(在工作中/猛烈抨击):
这就是我在接下来的项目中要做的……
<div class="list-group-item row" ng-repeat="item in list.items">
<a class="col-xs-6 col-sm-8 col-md-10 col-lg-10 pull-left" href="#/lists/{{list.id}}/items/{{item.id}}"><h5>{{item.name}} ({{item.quantity}})</h5></a>
<h5 class="col-xs-6 col-sm-4 col-md-2 col-lg-2 pull-right">
<a class="pull-left" href="#/lists/{{list.id}}/items/{{item.id}}/edit" ng-show="list.name !== 'all-deleted-items'"><u>Edit</u></a>
<a class="pull-right" href="" ng-click="removeItem(item, $event)" ng-show="list.name !== 'all-deleted-items'"><u>Remove Item</u></a>
</h5>
</div>这是我的项目中的工作代码--对粗糙的复制/粘贴表示歉意!较低的<h5>只是用于垂直对齐。添加到div.list-group-item的row类将占用整个容器宽度(可选)。
#注意事项:
不是所有的高度都可以作为一个链接,但这可能是一个不错的折衷方案。
希望这能有所帮助!
发布于 2015-01-13 06:30:40
听起来您希望整个list-group-item都是一个链接,这并不是通过提供的答案来实现的。您不能在另一个<a>标记中包含<a>标记,因此我认为您需要使用绝对定位来完成您要做的事情。
<div class="list-group-item" style="padding: 0;">
<a href="#" style="display: block; padding: 10px 15px;">test</a>
<a href="#" class="btn btn-sm btn-danger" style="position: absolute; top: 50%; right: 15px; margin-top: -15px;">hi</a>
</div>这应该和你想要的很接近。我只是添加了一些内联样式,以便快速地向您展示如何做到这一点,但您可能想要想出一些更通用的样式来方便地重用它。
https://stackoverflow.com/questions/27094505
复制相似问题