简体   繁体   中英

Border-radius not working with image

在此处输入图片说明

This is the code I currently have for this image

border-radius: 10px;
border: 3px solid transparent;
-moz-border-image: -moz-linear-gradient(top, #E2B0C7 0%, #BB96C2 100%);
-webkit-border-image: -webkit-linear-gradient(top, #E2B0C7 0%, #BB96C2 100%);
border-image: linear-gradient(to bottom, #E2B0C7 0%, #BB96C2 100%);
border-image-slice: 10;

I am trying to round the border corners by using:

border-radius: 10px;

But that is not rounding the corners for me. Any help is appreciated. Thank you in advance.

you must use the div and image into div. like this code

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8" />
    <style>
        div {
            background: linear-gradient(#ff0000 0%, #b200ff 50%, #ff0000 100%);
            padding: 10px;
            display: inline-block;
            border-radius: 20px;
        }
        img {
            width: 500px;
            border-radius: 20px;
            vertical-align: middle;
        }
    </style>
</head>
<body>
    <div>
        <img src="FK8.jpg" />
    </div>
</body>
</html>

best regards.

Border-radius and border-image are not the same; however, you can get this working with a ::after pseudo-element.

See updated fiddle: https://jsfiddle.net/2u44tqzy/1/

img {
    position: relative;
    border: 4px solid transparent;
    border-radius: 10px;
    background: linear-gradient(orange, violet);
    background-clip: padding-box;
    background: linear-gradient(to bottom, #E2B0C7 0%, #BB96C2 100%);
    /* just to show box-shadow still works fine */
    box-shadow: 0 3px 9px black, inset 0 0 9px white;
}

img::after{
    position: absolute;
    top: -4px; 
    bottom: -4px;
    left: -4px; 
    right: -4px;
    background: linear-gradient(to bottom, #E2B0C7 0%, #BB96C2 100%);
    content: '';
    z-index: -1;
    border-radius: 16px;
}

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