1

I've got a page with a thumbnail on it (more to come, so the float:left property is necessary). The thumbnail is a Div, with an anchor in it, in that anchor is an image and some text. The text is below the image. The ancho rinks to a pdf file. Simple.

http://www.bridgecitymedical.com/forms

The problem is that the text gets underlined on hover when you hover over it, and the thumb image gets a border and the text gets underlined when you hover over the thumb image. What I need is for then you hover over either the text or the image, that they BOTH get applied their respective hover states, e.g. image gets a border, text gets underlined. At the moment they function by themselves, but they need to be one, or it just looks odd.

Here's the markup:

<div class="form">
    <a href="/wp-content/uploads/forms/Adolescent New Patient Paperwork.pdf" target="_blank">
        <div class="form-wrapper">
        <div class="form-thumb">
            <img src="/forms/thumbs/1.jpg" alt="" />
        </div>
        Caption
        </div>
    </a>
</div>

and the css...

.form {
    margin: 30px;
    font-size:.8em;
    width: 137px;
    text-align: center;
}
.form-thumb{
    width: 125px;
    height: 150px;
    padding:5px;
    border: 1px solid rgba(0,0,0,.2);
    float:left
}
.form-thumb:hover{
    border: 1px solid #000;
}

The text underline comes from another part of the tylesheet by default.

Can I do this without javascript!?

Solved by Chris (selected answer). Here's his solution, with my thumb in a fiddle...

http://jsfiddle.net/7MLjZ/1/

2 Answers 2

3

Use the :hover state on .form-wrapper instead.

<div class='wrap'>
    <div class='thumb'></div>
    Text!
</div>



.wrap{width:60px; height:80px;}
.thumb{width:60px; height:60px; background-color:blue;}
.wrap:hover{text-decoration:underline;}
.wrap:hover .thumb{border:5px solid black;}

http://jsfiddle.net/7MLjZ/

Sign up to request clarification or add additional context in comments.

4 Comments

Oops, read your post wrong, so I deleted my first comment. BUT, it still does not work, as form-wrapper will put a border around the entire thumb, including the caption, I don't want the border around the caption too. :?
You're right. It needs split in to two statements. Check out the edit, and the jsfiddle.
YES! Just updated the site with the new css you provided. THANK YOU! Also... check my Original question for a link to your fiddle... I updated it to look like my thumb front he site.
Glad to hear it! Happy to help. :)
0

This should work to make both the image's div border and the caption's text black when hovered:

.form {
    margin: 30px;
    font-size:.8em;
    width: 137px;
    text-align: center;
}
.form-thumb{
    width: 125px;
    height: 150px;
    padding:5px;
    border: 1px solid rgba(0,0,0,.2);
    float:left
}

.form:hover .form-wrapper .form-thumb {
    border: 1px solid #000;
}

a:hover {
    color:#000;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.