How to get a

前端 未结 4 1597
耶瑟儿~
耶瑟儿~ 2021-02-20 06:31

I have below code in html page:

\"image_not\"

in css page the below code:

相关标签:
4条回答
  • 2021-02-20 06:36

    Actually you CAN focus an <img> - with the help of tabindex:

    img:focus {
        outline: 2px solid blue;
    }
    <img src="http://www.w3schools.com/images/w3logotest2.png" tabindex="0">

    0 讨论(0)
  • 2021-02-20 06:52

    Try using the border property instead of the outline property. It should look like:

    img:hover {
        border: 2px solid blue;
    }
    

    Edit: Use hover instead of focus

    0 讨论(0)
  • 2021-02-20 06:57

    If its an anchor tag you can also use

    A:focus img{border: 2px solid blue;}

    0 讨论(0)
  • 2021-02-20 06:58

    You can't "focus" an image unless you have an interactive element or navigate to it using tab. Try adding an interactive element on a wrapper div like so:

    Html

    <a class="imageAnchor" href="#">
        <img id="image_java" alt="image_not" src="http://www.w3schools.com/images/w3logotest2.png" />
    </a>
    

    CSS

    .imageAnchor:focus img{
        border: 2px solid blue;
    }
    

    http://jsfiddle.net/4x7wg7sb/1/

    0 讨论(0)
提交回复
热议问题