Home > Web Front-end > CSS Tutorial > Background that automatically scales with content using CSS3 duration

Background that automatically scales with content using CSS3 duration

高洛峰
Release: 2017-03-17 09:57:19
Original
1642 people have browsed it

CSS3 brings us a very practical new attribute: border-image. Using this attribute, we can make a background that automatically scales as the content increases or decreases. Without further ado, let’s look at the code!
HTML:
<ol> <li>First list content</li> <li>Second list content</li> <li>Third item List content</li> <li>Fourth list content</li> <li>Fifth list content</li> </ol>
CSS:
border: 20px solid; <a href="http://www.php.cn/wiki/835.html" target="_blank">width</a>: 200px; -webkit-border-image: url(border.png) 30 30 round;
Rendering:

使用CSS3时限随内容自动伸缩的背景

Now we add list entries and take a look at the rendering:

使用CSS3时限随内容自动伸缩的背景

As the number of lists increases, the background automatically becomes larger, which is very good!
This is border.png:

使用CSS3时限随内容自动伸缩的背景

## You may have questions about the 30 30 in border-image:


-webkit-border-image : url(border.png) 30 30 round;Look at the picture below:

使用CSS3时限随内容自动伸缩的背景

My personal understanding of the two values ​​​​in the border-image above is, The first one indicates how many pixels the top and bottom of the picture "eat" from the edge as the border. Correspondingly, the second value indicates the left and right. The remaining middle area will be repeated (or stretched) as the background.

You may still have a question, the size of the stroke:
border: 20px solid;Let’s take a look at what it looks like when the stroke is 50 pixels:

使用CSS3时限随内容自动伸缩的背景

So now you understand.

As for the color of the stroke, it won’t be displayed, so it doesn’t matter whether you write it or not.
Okay, now you know how to make this kind of background that automatically scales with the content, you can practice it!


The above is the detailed content of Background that automatically scales with content using CSS3 duration. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template