Use CSS to implement diamond-shaped images, diagonal stripe backgrounds

Source: Internet
Author: User

Relatively simple diamond Picture: The effect is as follows

Code section:

<div class= "D1" >    </div>. d1{margin-left:100px        ;        Display:inline-block;        Transform:rotate (45deg);        Overflow:hidden;    }    . d1>img {        max-width:100%;        max-height:100%;        Transform:rotate ( -45deg) scale (1.42);  }

  

The background principle of diagonal stripes is similar but the steps are different:

The first step: we want to achieve the following effect:

CSS section: We have at least four textures to create//* * * Here the 0 refers to the end of the previous color of the place * * *

. d3 {
Background:linear-gradient (#fb3 25%, #58a 0, #58a 50%, #fb3 0, #fb3 75%, #58a 0);
    background-size:100% 30px;   Using background-size Sizing
    Background-repeat:no-repeat;  
}
 

  

Second step: Using Tansform to rotate the background, the effect is as follows: Then use the default tile:

CSS section:

. d4 {
Background:linear-gradient (45deg, #fb3 25%, #58a 0, #58a 50%, #fb3 0, #fb3 75%, #58a 0);
background-size:40px 40px;
}

 

But the above method only achieves a 45-degree diagonal stripe background When this method is in the case of 60 degrees, the following occurs:

Because of the change in the degree, we need to recalculate each repeat color block size, but the general idea is clear, and then the following is the ultimate solution:

No matter whether it's 60 degrees or 75 degrees or other specified tilt values, it's easy to handle.

60deg 75deg

. d5 {        background:repeating-linear-gradient (75deg, #fb3, #fb3 15px, #58a 0, #58a 30px);        /* Finally easier way to repeating-linear-gradient tiling linear gradients */  }

  

  

Use CSS to implement diamond-shaped images, diagonal stripe backgrounds

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.