Background image does not show in tag

后端 未结 3 1170
悲&欢浪女
悲&欢浪女 2021-01-27 11:02

I use bootstrap 3. I try to use \"icon link\" by using tag as shown below:

HTML:


CSS:
.link         


        
3条回答
  •  青春惊慌失措
    2021-01-27 11:23

    The anchor element has no content, and it has no styles that would affect it's dimensions, consequently it has an effective area of zero square pixels.

    The background image is probably being applied just fine, you can't see it because there is no area on which it can be displayed.

    The code implies that the image is there to tell the visitor where the link goes, that would mean that the image is content and not background and should be expressed as an image element (which would take on the dimensions of the image file automatically).

    Using an image element also provides you with the opportunity to supply alt text for the benefit of screen readers / search engines / people with internet connections that briefly fell over while loading the image / etc.

    top of page
    

提交回复
热议问题