CSS-边框1-边框背景图

1、边框背景概述

1.1 border-image-source

border-image-source属性指定要使用的图像,而不是由border-style属性设置的边框样式。如果值是"none",或者,如果无法显示图像,边框样式会被使用。

1.2 border-image-slice

border-image -slice属性指定图像的边界向内偏移。

说明
number 数字表示图像的像素(位图图像)或向量的坐标(如果图像是矢量图像)
% 百分比图像的大小是相对的:水平偏移图像的宽度,垂直偏移图像的高度
fill 保留图像的中间部分

1.3 border-image-repeat

描述
stretch 默认值。拉伸图像来填充区域
repeat 平铺(repeated)图像来填充区域。
round 类似 repeat 值。如果无法完整平铺所有图像,则对图像进行缩放以适应区域。

1.4 border-image-width

border-image-width 属性的四个之规定将边框图像分割为九个部分的偏移。它们代表了从区域的上、右、下、左侧向内的距离。如果忽略第四个值,则与第二个值相同。如果省略第三个值,则与第一个值相同。如果省略第二个值,则与第一个值相同。不允许任何负值作为 border-image-width 值。

描述
length 距离多少像素
percentage 百分比
number 边框宽度多少倍数

1.5 border-image-outset

border-image-outset 属性规定边框图像超出边框盒的量。在上、右、下、左侧。如果忽略第四个值,则与第二个值相同。如果省略第三个值,则与第一个值相同。如果省略第二个值,则与第一个值相同。不允许任何负值作为 border-image-outset 值。

描述
length 距离多少像素
percentage 百分比
number 边框宽度多少倍数

2、背景裁剪

border-image-slice :上、右、下、左。


边框背景图剪裁

3、边框背景重复效果

源代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>边框背景重复效果</title>
    <style type="text/css">
    .borderImage{
        width:400px;
        height:100px; 
        border: 27px double orange; 
        border-image-source:url(border.png);
        border-image-slice: 27 27 27 27;
        border-image-width: 27px;
        border-image-repeat: stretch;
    }
    .borderImageRepeat{
        margin-top: 50px;
        width:400px;
        height:100px; 
        border: 27px double orange; 
        border-image-source:url(border.png);
        border-image-slice: 27 27 27 27;
        border-image-width: 27px;
        border-image-repeat: repeat;
    }
      .borderImageRound{
        margin-top: 50px;
        width:400px;
        height:100px; 
        border: 27px double orange; 
        border-image-source:url(border.png);
        border-image-slice: 27 27 27 27;
        border-image-width: 27px;
        border-image-repeat: round;
    }
    </style>
</head>
<body>
    <div class="borderImage">border-image-repeat: stretch;</div>
    <div class="borderImageRepeat">
        border-image-repeat: repeat;<br>
        repeat简单粗暴,会有不完整的情况。
    </div>
    <div class="borderImageRound">
        border-image-repeat: repeat;<br>
        round会拉伸压缩比repeat效果好。
    </div>
</body>
</html>

运行效果:

背景图重复
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • CSS边框属性 元素的边框就是围绕元素内容和内边距的一条或多条线。 元素的边框属性: border 简写属性,用...
    Zd_silent阅读 4,606评论 0 1
  • 选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...
    wzhiq896阅读 5,899评论 0 2
  • 选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...
    love2013阅读 6,861评论 0 11
  • 此文涉及的内存管理是针对于继承于NSObject的Class。 一基本原理 Objective-C的内存管理机制与...
    小热狗阅读 3,547评论 0 0
  • 三生之前,我就想过,我将会来到这里,这里芳香四溢,绿草如茵,夜莺在枝柯间婉转,啼出如幻的音律。 哦,山坡上,那玫瑰...
    宁木紫菀阅读 3,025评论 0 2

友情链接更多精彩内容