html语言中style中image,HTML Style borderImage用法及代码示例

HTML中的DOM样式borderImage属性是用于设置borderImageSource,borderImageSlice,borderImageWidth,borderImageOutset和borderImageRepeat属性的简写属性。

用法:

它用于返回borderImage属性。object.style.borderImage

它用于设置borderImage属性。object.style.borderImage = "source slice width outset repeat|

initial|inherit"

属性值:在borderImage属性中,有7个属性值,如下所述:

border-Image-Slice:此参数指定image-border的向内偏移。

initial:此属性值用于将此属性设置为其默认值。

inherit:此属性值用于从其父元素继承此属性。

返回值:

它返回一个字符串值,该字符串值表示元素的border-image属性。

示例1:这显示了如何更改border-image。

#my {

border:50px solid transparent;

width:250px;

padding:15px 15px;

-webkit-border-image:

url(https://media.geeksforgeeks.org/wp-content/uploads/bord-1-300x161.jpg)

100 100 stretch;

-o-border-image:

url(https://media.geeksforgeeks.org/wp-content/uploads/bord-1-300x161.jpg)

100 100 stretch;

border-image:

url(https://media.geeksforgeeks.org/wp-content/uploads/bord-1-300x161.jpg)

100 100 stretch;

}

Click the "Change" button to change the border-image property

Change

GeeksForGeeks

function myFunction() {

document.getElementById("my").style.WebkitBorderImage =

"url(https://media.geeksforgeeks.org/wp-content/uploads/bord1-1-300x162.jpg)30 30 round";

document.getElementById("my").style.OBorderImage =

"url(https://media.geeksforgeeks.org/wp-content/uploads/bord1-1-300x162.jpg)30 30 round";

document.getElementById("my").style.borderImage =

"url(https://media.geeksforgeeks.org/wp-content/uploads/bord1-1-300x162.jpg)30 30 round";

}

输出:

之前单击按钮:

6e62a659a8bfbdf69e052982c97c73c0.png

单击按钮后:“图像的边框已更改”

a006ec383453c9e8b835272645b78449.png

示例2:样式borderImageSource属性。

div {

border:30px solid transparent;

border-image:

url(https://media.geeksforgeeks.org/wp-content/uploads/bord1-1-300x162.jpg);

border-image-slice:30;

border-image-width:1 1 1 1;

border-image-outset:0;

border-image-repeat:round;

}

Here are the two images used:

    p

"https://media.geeksforgeeks.org/wp-content/uploads/bord-1-300x161.jpg"

height="100" width="100">

    p

"https://media.geeksforgeeks.org/wp-content/uploads/bord1-1-300x162.jpg"

height="100" width="100">

GeeksForGeeks

Click the "Change" button to change the value of the borderImageSource property.

Change

function myFunction() {

document.getElementById("main").style.borderImageSource =

"url(https://media.geeksforgeeks.org/wp-content/uploads/bord-1-300x161.jpg)";

}

输出:

之前单击按钮:

67a7e1f15ffaccc5b7ee9dd497940696.png

单击按钮后:

cf1e7bf0ac47524852e5f321999a8735.png

支持的浏览器:下面列出了DOM Style borderImage属性支持的浏览器:

谷歌浏览器1.0

Internet Explorer 4.0

Firefox 1.0

Opera 3.5

Safari 1.0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值