简体   繁体   中英

Twitter-Bootstrap: text underlining in the caption of a thumbnail

Working with Bootstrap I wanted to make a replica of http://spring.io/projects ; a grid of links that are each a bordered panel (might not be the right word...) with some words an a picture inside. I've come to a conclusion, that Bootstrap's Thumbnail component should be right for me.

Having tried to use it, however, I ran into a problem.

If I want the entire panel to be clickable, I have to apply the thumbnail class to an anchor tag (wrapping the anchor into a div with thumbnail doesn't seem to work). Then, inside the anchor tag I've got a div tag with the class caption in it to store some text whose styling I don't want to change upon hovering on the panel.

What this caused is this: the text regained normal colour (as compared to the link colour when used without the caption class, however hovering over the panel causes the text to get underlined, and I'd prefer if that was not the case: it doesn't look very good and the highlight of the border upon hover is already a good indicator of that it is indeed a link.

I was about to just get my css hat out and modify the caption class to not do this, but it doesn't seem like the right course of action; I can't imagine it being desirable behavior for captions to get highlighted like this, and I'd like to use as little custom code as possible (since sticking to standards means I won't have to maintain this code every time I update bootstrap).

So my question is: where am I going wrong? Is it actually bad practice to want the entire thumbnail panel to work as a link? Or should I go ahead and manually scrape the underlining off? Or am I maybe applying wrong classes to wrong tags? Or is the thumbnail component not a right component for me to use altogether in such a case?

EDIT:

Forgot to include the code.

The thing I'm currently using:

<a class="thumbnail text-center" href="#">
    <div class="caption">
        <h3>Potato</h3>
        <p>Some short description of what this exact potato really is about.</p>
    </div>
</a>

EDIT 2:

Adding an image of what is currently occurring:

This is with the mouse hovering over it; as you can see, the text is underlined, which is not ideal.

Really weird that you ask this question because I just read a thread on this not so long ago and still have my solution which I have turned into a FIDDLE for you.

If I understand your question correctly, you want the entire panel / div to be a link, which can be accomplished like this: (This is the OP's steps, cant remember them word for word)

  1. Make your Div position: Relative;
  2. create a link <a href="#"></a>
  3. put span tags into that link <span></span>
  4. Style the empty span tag with

CSS:

{ 
  position:absolute; 
  width:100%;
  height:100%;
  top:0;
  left: 0;

  /* edit: added z-index */
  z-index: 1;

  /* edit: fixes overlap error in IE7/8, 
     make sure you have an empty gif */
  background-image: url('empty.gif');
}  

I think that's all there is to it. Like I said... There is a thread somewhere on this, but I cant remember what it was called.

Hope this can help.

EDIT: So after a long debate, we can forget about the above AND we came to the conclusion that this is possibly what you are after? :)

Add a tiny bit more CSS to your solution and you are sorted...

a.thumbnail:link {
text-decoration:none;
cursor:pointer;
}

Here is an updated fiddle

The solution is to add on the top of your style sheet:

    a:hover {
      text-decoration: none;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM