admin管理员组文章数量:1424902
I want do a bootstrap panel clickable. But not the head clickable. ALL the panel clickable. I'm trying but when I add my div into <a>
all content is linkable, and I dislike this text blue by links...
<div class="panel panel-default">
<a href="#">
<div class="panel-body">
...
</div>
<div class="panel-footer">
<div class="row">
...
</div>
</div>
</a>
</div>
How can do my bootstrap panel clickable?
Thanks!
I want do a bootstrap panel clickable. But not the head clickable. ALL the panel clickable. I'm trying but when I add my div into <a>
all content is linkable, and I dislike this text blue by links...
<div class="panel panel-default">
<a href="#">
<div class="panel-body">
...
</div>
<div class="panel-footer">
<div class="row">
...
</div>
</div>
</a>
</div>
How can do my bootstrap panel clickable?
Thanks!
Share Improve this question edited Jun 17, 2016 at 12:31 Zakaria Acharki 67.5k15 gold badges78 silver badges106 bronze badges asked Jun 17, 2016 at 12:00 user3745888user3745888 6,35315 gold badges49 silver badges101 bronze badges 2- Is there a reason you're not using Lists for this? – Stubbies Commented Jun 17, 2016 at 12:04
- 2 "and I dislike this text blue by links" - then style it differently! – Turnip Commented Jun 17, 2016 at 12:06
2 Answers
Reset to default 5You could style it, and better if you could add a class for clickable ones so that will not affect others :
<div class="panel panel-default clickable-panel" data-href=''>
...
</div>
CSS :
.clickable-panel a:hover, .clickable-panel a:active {
color: #000;
text-decoration: none;
}
Or if you don't want to use a
tag you could add a CSS attribute cursor
to the class panel
that have data-href
attribute that will make it clickable :
.panel[data-href]{
cursor: pointer !important;
}
Then add data-href
that contain the link you want to redirect to, example :
<div class="panel panel-default" data-href=''>
...
</div>
Then in your JS code add event :
$('body').on('click', '.panel[data-href]', function(){
if(window.location.hash) {
window.location.hash = $(this).data('href');
} else {
window.location.href = $(this).data('href');
}
})
Hope this helps.
$('body').on('click', '.panel[data-href]', function(){
if(window.location.hash) {
window.location.hash = $(this).data('href');
} else {
window.location.href = $(this).data('href');
}
})
.panel[data-href]{
cursor: pointer !important;
}
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://netdna.bootstrapcdn./bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link href="https://netdna.bootstrapcdn./bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="panel panel-default" data-href='#test'>
<div class="panel-body">
Go to test div
</div>
<div class="panel-footer">
<div class="row">
...
</div>
</div>
</div>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<div id='test'>
TEST DIV
</div>
You could just remove all styling of links from your panel :
.panel-default a:link, .panel-default a:hover, .panel-default a:visited, .panel-default a:active {
color: #000;
text-decoration: none;
}
<link href="https://maxcdn.bootstrapcdn./bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="panel panel-default">
<a href="#">
<div class="panel-body">
...
</div>
<div class="panel-footer">
<div class="row">
...
</div>
</div>
</a>
</div>
本文标签: javascriptHow to make all the bootstrap panel clickableStack Overflow
版权声明:本文标题:javascript - How to make all the bootstrap panel clickable? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745407524a2657317.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论