Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i make entire bootstrap panel as hyperlink

am using twitter bootstrap's panel component. i have below code

<div class="panel panel-info">
            <div class="panel-heading">
                <div class="row">
                    <div class="col-xs-6">
                        <i class="fa fa-comments fa-5x"></i>
                    </div>
                    <div class="col-xs-6 text-right">
                        <p class="announcement-text">My queue</p>
                    </div>
                </div>
            </div>
        </div>

how do i make the entire panel as hyperlink. like i should be able to click on any part of the panel and it should navigate to a different page.

Online examples show making the footer as hyperlink, but i thought it would be better if i can make the entire panel a hyperlink.

i don't want to use metro.js.

Thanks.

like image 702
user1447718 Avatar asked Dec 04 '13 00:12

user1447718


People also ask

How do I add a link to a bootstrap table?

bootstrapTable('insertRow', { index: 0, row: { id: obj.id, name: obj.name, action: obj.id } }); } function ActionFormatter(value) { return '<a href="javascript:void(0)" onclick="Details('+ value +')">Details</a>'; } function Details(id){ ... }

What is a stretched link?

stretched-link to a link to make its containing block clickable via a ::after pseudo element. In most cases, this means that an element with position: relative; that contains a link with the . stretched-link class is clickable.

How do I change the size of a panel in bootstrap?

Bootstrap panels will fit just fine inside Bootstrap's columns. Try wrapping the full set of <a> tags in a <div class="container"> and <div class="row"> , then give each <a> tag a column class like col-md-6 (two 50% width columns at larger screen sizes, switching to a single full-width column at smaller screen sizes).


2 Answers

Using an anchor tag around the element can mess up some layouts due to ancestor selectors in the stylesheet.

Using an anchor tag as the panel itself also may not inherit from the default panel styles.

The simplest solution with javascript is to put an attribute on the panel div, like href or data-href, then a global event listener (delegate).

 $(document).on('click', '.panel[data-href]:not(a)', function(){
     window.location = $(this).attr('data-href');
 });
like image 154
stephenr85 Avatar answered Sep 27 '22 16:09

stephenr85


Just wrap the whole panel in an anchor tag.

 <a href="link.com">    
  <div class="panel panel-info">
    <div class="panel-heading">
      <div class="row">
        <div class="col-xs-6">
          <i class="fa fa-comments fa-5x"></i>
        </div>
        <div class="col-xs-6 text-right">
          <p class="announcement-text">My queue</p>
        </div>
      </div>
    </div>
  </div>
</a>
like image 26
Alan Thomas Avatar answered Sep 27 '22 16:09

Alan Thomas