Image won't load with “content: url()” in Inte

2019-04-10 03:18发布

问题:

I'm working on a website and my website has to work in Chrome and in Internet Explorer 9. I'm almost finished and I have only one problem left. If i want to load an image with "content: url()" it works perfectly in Chrome but not in IE9. Can somebody please give me another solution where I where i don't have to change my HTML.

My HTML:

<!DOCTYPE html>
 <html lang="nl">
 <head>
  <title>Test</title>
  <meta charset="utf-8" />
  <link rel="stylesheet" href="test.css" />
 </head>
 <body>
  <header>
  </header>

  <a id="photo">Photo</a>

  <footer>
  </footer>
 </body>
</html>

My css:

#photo {
 content: url('right-button.png');
}

回答1:

Try this:

#photo {
    background: url("right-button.png") no-repeat;

}

For more informations read here some articles i found for content attribute:

content property,W3c