Right now I am trying to insert a glyphicon or button within a list-group-item. What I want is that when the user clicks anywhere within the list-group-item, they are linked to a certain page, but when they click the glyphicon or button, they link to another page. Why I try to do this, it keeps putting the glyphicon or button outside of the list-group-items box. Why is this? How can I fix this?
Much appreciated.
Code:
<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>
here you go:
<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;
}
fiddle: http://jsfiddle.net/9r14uuLw/
Pardon the brevity (at work / slammed):
<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>
This is working code from my project -- apologies for the crude Copy/Paste! The lower <h5>
is simply for vertical alignment. The row
class added to div.list-group-item
is to take up full container width (optional).
Not the entire height is actionable as a link, but this may be a decent compromise.
Hope this helps!
It sounds like you want the entire list-group-item to be a link, which is not accomplished by the answer provided. You can't have an <a>
tag inside another <a>
tag, so I think you need to use absolute positioning to accomplish what you are trying to do.
<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>
That should be close to what you're after. I just added some inline styles to quickly show you how it can be done, but you'll probably want to come up with some more generic styles to re-use this easily.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With