border-image简介
css3中新增了一个属性border-image,这个属性允许开发者使用图片来定义边框,扩充了 CSS2 中仅有的几个预定义边框样式(border-style)。
border-image 是一个简写属性,分别设定了以下几个属性。
border-image-source
border-image-slice
border-image-width
border-image-outset
border-image-repeat
为什么图片可以作为边框?
在开始学习border-image之前我有一个疑问,图片是怎么应用到容器的边框上的?
看下图
简单的说就是把图片的中间部分去掉,从而形成一个类似边框的框架。
那么如何使用被划分出来的八格素材来生成一个边框呢?
左上、右上、左下、右下的四格素材分别作为边框的四个角,而上下左右的四格素材分别经过不同形式的扩展,形成边框的四条边。上图很好的说明了图片形成边框的处理形式。
border-image-source
border-image-source属性用来指定边框所需素材的路径,语法可以参照backgound-image。
需要注意的是,如果只设置了border-image-source属性而其他属性使用缺省值,则边框素材不会被划分九宫格,而是将整个素材按照边框宽度缩放至合适尺寸后安放在边框四角。
<!doctype html><html><head><meta charset="utf-8"><title>边框图片</title><style>#border_image { width:100px; height:100px; border:15px solid #ccc; border-image:url("http://img.mukewang.com/52e21fea000127e802100210.jpg"); background:#ccc; }</style></head><body><div id="border_image"></div></body></html>
如下图
border-image-slice
border-image-slice属性用来设置边框素材的切割尺寸,如下图,依次是上横切割线,右竖切割线,下横切割线,左竖切割线。数值分别代表从上、右、下、左边缘向素材中心延伸的像素/百分比数
注意:切割的数值只接受像素和百分比两个单位,并且像素单位必须省略,即只接收数值或者百分比的形式。例如,border-image-slice: 10 10 30 10代表图片素材按照下图的样式被切割:
border-image-width
border-image-width用来设置边框素材的宽度,当同时设置了border-image-width和border-width属性时,那么边框的实际宽度由border-width属性决定。此时,如果border-image-width属性小于border-width属性,边框图片会沿边框的外侧分布而内侧留空形成 padding 的效果;如果border-image-width属性大于border-width属性,边框图片会仍会沿边框的外侧分布而内测溢出,如下图
border-image-repeat
border-image-repeat属性用来设置上下左右四边(即2、4、5、7四个素材块)的重复形式,分别有stretch repeat round space四个取值
stretch:指定用拉伸方式来填充边框背景图。
repeat:指定用平铺方式来填充边框背景图。当图片碰到边界时,如果超过则被截断。
round:指定用平铺方式来填充边框背景图。图片会根据边框的尺寸动态调整图片的大小直至正好可以铺满整个边框。
space:指定用平铺方式来填充边框背景图。图片会根据边框的尺寸动态调整图片的之间的间距直至正好可以铺满整个边框。
border-image-outset
border-image-outset属性会产生使 border-image 相对于原始位置向外侧推移的效果,设置border-image-outset属性会使 border-image 溢出,但不会影响整个盒模型的尺寸,因此在设置此属性时要特别注意防止元素间的相互干扰。
如下图
后续
border-image是css3属性所以存在兼容性问题,需要在属性前面设置-webkit等

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)