ここで私のデモ: https://codepen.io/joondoe/pen/MWwmGwG?editors=0100
私の例では CSS を使用していますが、SVG を使用したソリューションも受け入れています。
内部にコンテンツを埋めるボーダー画像を作成することができました。今、100% 滑らかな境界線画像を作成できるかどうか疑問に思っていますか? つまり、元のボーダー画像を自動的に再現するボーダー画像、またはプログラムで可能な限り近い画像です。
私のデモでは、かなり問題ないことがわかりますが、元の境界線の画像に比べてエイリアシングとラグがまだいくつかあります. 元のボーダー画像は次のとおりです。
ここに私のコード:
.container {
background-color: #444;
width: 300px;
height: 350px;
padding: 20;
margin: 0;
display: flex;
align-items: center;
justify-content: center;
border: solid ;
border-width:15px 30px 30px 25px;
border-image:url( https://i.imgur.com/Z6TVgss.png)40 stretch;
overflow:hidden;
box-sizing:content-box; background:url(https://www.ecopetit.cat/wpic/mpic/6-67359_race-car.jpg) center/cover no-repeat content-box;
}
div.element {
width: 50px;
height: 50px;
mask-image: url( https://i.imgur.com/Z6TVgss.png);
};
div.icon-image {
mask-size: 100% 100%;
mask-position: 0% 0%;
mask-repeat: no-repeat;
display: flex;
/* border: 1px solid orange; */
flex-direction: column;
align-items: center;
justify-content: center;
}
div.icon-image img {
width: 100%;
}
<div class="container">
<div title="" class="icon-image element"></div>
</div>
CSSまたはSVGのプログラム機能のみを使用して元の境界線の画像を再現する方法はありますか?パーセンテージ、塗りつぶしプロパティなどすべて?
編集: このソリューションのTermani Afifに感謝します。 Termani Afif の anwser の画像にピクセルのギャップがあったことに驚いたので、おそらく私のボーダー画像とマスクはそのように言うのに自由ではなかったと思いました。だから私は他の画像で再構成しました、そしてそれは非常にうまく機能します、ここでデモ: codepen.io/joondoe/pen/GRJmBQK?editors=0100