简体   繁体   English

如何获得图像链接周围的:focus轮廓以不将其切断?

[英]How can I get the :focus outline around an image link to not cut it off?

I'm trying to change the look of the focus outline for when someone is tabbing through the website. 我正在尝试更改焦点轮廓的外观,以供有人在网站上浏览时使用。 The CSS I'm using is below: 我正在使用的CSS如下:

:focus { outline: solid 6px orange; outline-offset: 3px }

The image link is generated using the below html: 图片链接是使用以下html生成的:

<A href="http://www.google.com"><IMG src="http://us.usablenet.net/mt/a/hyatt.com/l1398691219000/icons/info.png"></A>

However for a link that has an image, this style is cutting through the image instead of around it. 但是,对于具有图像的链接,此样式将贯穿图像而不是图像周围。 I can't post images, but here is the imgur link to the related screenshots taken from when I was trying to debug the issue on the Tryit Editor from w3schools 我无法发布图像,但是这里是imgur链接,指向当我尝试从w3schools在Tryit Editor上调试问题时获取的相关屏幕截图

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

jsFiddle http://jsfiddle.net/k6vsckue/ jsFiddle http://jsfiddle.net/k6vsckue/

a elements are displayed inline by default. a元素显示inline默认。 The height property of inline elements cannot be change and so the image is overflowing out of the container. 内联元素的height属性无法更改,因此图像溢出了容器。 The outline on the a element then appears to 'cut' through it. 然后, a元素上的轮廓似乎“切入”了它。

You can, however, change the display type to inline-block so the a's height will change to fit its image and achieve the effect you want. 但是,您可以将显示类型更改为inline-block这样a的高度将发生变化以适合其图像并达到您想要的效果。

CSS 的CSS

A { display:inline-block; }

Live example: http://jsfiddle.net/5ho7rf46/ 实时示例: http//jsfiddle.net/5ho7rf46/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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