CSS Stripe background

Source: Internet
Author: User

First introduce the two knowledge points used in the article

Background-size Property

Grammar

Length| percentage|cover|contain;
Length

Sets the height and width of the background image.

The first value sets the width, and the second value sets the height.

If you set only one value, the second value is set to "Auto".

Percentage

Sets the width and height of the background image as a percentage of the parent element.

The first value sets the width, and the second value sets the height.

If you set only one value, the second value is set to "Auto".

Cover

Expand the background image to be large enough to allow the background image to completely cover the background area.

Some parts of the background image may not appear in the background positioning area.

Contain Extend the image image to the maximum size so that its width and height are fully adapted to the content area.

CSS linear gradient linear-gradient (to <side-or-corner>) | | <angle>,<color-stop>,<color-stop>)

<side-or-corner> = [left | right] | | [Top | bottom]

Specifies the direction (or angle) of the gradient with an angle value.

<color-stop> = <color> [<length> | <percentage>]

Background:linear-gradient (to top,red, blue);

Let's Change the code:

Background:linear-gradient (to top,red 50%, Blue 50%);
background-:

Into:

Rewrite again:

Background:linear-gradient (to top,red 50%, Blue 50%);             background-size:100% 30px;
Horizontal stripes appear

A horizontal stripe effect is formed by coincident the percentage behind the color, where the color label is located.

It is also possible to write more than two colors:

Background:linear-gradient (to top,red 33.3%, blue 0%,blue 66.7%,pink 0);            background-size:100% 90px;

Vertical stripes

Originally the same horizontal stripe, just change the background-size and linear=gradient gradient direction

Background:linear-gradient (to right,red 33.3%, blue 0%,blue 66.7%,pink 0); background-size:90px 100%;

Difficulty: diagonal Stripes

CSS Stripe background

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.