This time I will bring you CSS3 to make a striped background. What are the precautions for using CSS3 to make a striped background? The following is a practical case, let’s take a look.
1. To achieve unequal width background stripes:
.cont{ width: 500px; height: 200px; background: linear-gradient(#78C9DB 70%,#0acf00 0%); background-size: 100% 20px; }
2. Tile striped background
.cont{ width:500px; height:200px; background:linear-gradient(45deg,#78C9DB 50%,#0acf00 50%); background-size:30px 30px; }
3. Grass background
.cont{ width:500px; height:200px; background:linear-gradient(-45deg,#0acf00 50%,#78C9DB 50%); background-size:30px 100%; }
4. Diagonal striped background
.cont{ width:500px; height:200px; background:linear-gradient(-45deg,#0acf00 25%,#78C9DB 0,#78C9DB 50%,#0acf00 0,#0acf00 75%,#78C9DB 0); /*background:repeating-linear-gradient(-45deg,#0acf00,#0acf00 15px,#78C9DB 0,#78C9DB 30px);*/效果相同 background-size: 30px 30px; }
5. Monochrome diagonal striped background (use transparency and transparent)
.cont{ width:500px; height:200px; background:#fff repeating-linear-gradient(30deg,rgba(0,0,0,.5),rgba(0,0,0,.5)15px,transparent 0,transparent 30px); }
6. Plaid shirt background
.cont{ width:500px; height:200px; background:#fff; background: linear-gradient(90deg,rgba(100,0,0,.5) 50%,transparent 0),linear-gradient(rgba(100,0,0,.5) 50%,transparent 0); background-size: 30px 30px; }
7. Wave dot background
.cont{ margin:50px; width:500px; height:200px; background:#a95f44; background-image:radial-gradient(#fff 30%,transparent 0),radial-gradient(#fff 30%,transparent 0); background-size:20px 20px; background-position:0 0,10px 10px; // 必须是background-size尺寸的1/2 }
8.Chessboard background
.cont{ width:500px; height:200px; background: #fff; background-image:linear-gradient(45deg,#a95f44 26%,transparent 0,transparent 75%,#a95f44 0), linear-gradient(45deg,#a95f44 26%,transparent 0,transparent 75%,#a95f44 0); background-size:30px 30px; background-position:0 0,15px 15px; }
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website! Recommended reading:
CSS3 dynamic prompt effect when the mouse moves into the picture
How to use the sticker-footer layout in css
The above is the detailed content of Create a large striped background with CSS3. For more information, please follow other related articles on the PHP Chinese website!