Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show on Click - CSS, HTML5

Tags:

html

css

I've got a quick question:

I've got a quick table, in which there's something clickeable.

<table class ="tablez">
    <tr>
        <th>Table Title </th>
    </tr>
    <tr>
        <td>
            <a class="clickable">Click Me!</a>
            <div id="showedClickable">
                <p>This is showed when Click Me! is clicked.</p> 
            </div><!--EO showedClickable -->
        </td>
    </tr>
</table>

What I want to accomplish is:

#showedClickable {
    position:absolute;
    display:none;
    width:auto;
    height:auto;
}

This is the part I don't know how to 'phrase'...How do I do so that

a.clickable:focus + #showedClickable {
    display:block;
}
like image 443
user1876553 Avatar asked May 25 '26 15:05

user1876553


1 Answers

The problem is that an a element without a href does not receive focus by default. This is why your code is not working. You should give it a tabindex to make it focusable.

<a tabindex="0" class="clickable">Click Me!</a>

jsFiddle Demo

like image 173
kapa Avatar answered May 28 '26 04:05

kapa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!