简体   繁体   中英

Setting rounded corners(Border radius) for Internet explorer IE6+

I am trying to get rounded corners in IE6, 7 and 8 using ie-css3.htc source: http://fetchak.com/ie-css3/

here is css class:

.box {
   position: absolute;
   display: block;  

background:  url(images/img.gif) no-repeat top left;
    -moz-border-radius: 15px; /* Firefox */
    -webkit-border-radius: 15px; /* Safari and Chrome */
    border-radius: 15px; /* Opera 10.5+, future browsers, and now also Internet Explorer 6+ using IE-CSS3 */

   height: 200px;
   width: 350px;

    behavior: url(ie-css3.htc); /* This lets IE know to call the script on all elements which get the 'box' class */
  }

When I apply it to div it works(get rounded corners):

<div class="box" />

But when I apply it to image tag it doesn't work,

<img class="box" src="images/img.gif" />

is there workaround for this, because I need it to work, for image tag.

It doesn't work because on IE, your <img> has a background of img.gif . The background-image is well rounded. But as it's a <img> tag, it also has a (square) image in it, displayed over the background. So even if your background is rounded, the image inside is not.

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