简体   繁体   中英

Href in li tag doesn't work

This is my code:

             <li>
                <figure>
                    <img src="images/1.png" alt="img04">
                    <figcaption>
                        <h3>Text</h3>
                        <span>Text</span>
                        <a href="#screen" class="cd-modal-trigger">View</a>
                    </figcaption>
                </figure>
            </li>

I want, when I click on the image, href go to #screen. But when i try this:

<img src="images/1.png" alt="img04" href="#screen">

It doesn't work.

So is there a way when you click on the image, you go to #screen ?

So is there a way when you click on the image, you go to #screen ?

When you click on the text View , you go to #screen. This is because the text is inside an <a> with an href attribute.

You do exactly the same thing to the image that you did to the text if you want the same effect when you click on the image.

Wrap the <img> in an <a> element. Put the href attribute on the <a> element.

尝试这个 :

<a href="#screen"><img src="images/1.png" alt="img04"></a>

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