CSS3做出條紋大背景

來源:互聯網
上載者:User
這次給大家帶來CSS3做出條紋大背景,使用CSS3做出條紋大背景的注意事項有哪些,下面就是實戰案例,一起來看一下。

1. 實現不等寬背景條紋:

.cont{width: 500px;height: 200px;background: linear-gradient(#78C9DB 70%,#0acf00 0%);background-size: 100%  20px;}

如果想設定等寬的漸層只需要將開始值和結束值改為互補

如果你需要等寬切無過渡的漸層,開始和結束值設定為50%即可。

如果你想要垂直條紋,你只需要調整background-size的x、y值即可。

2.瓷磚條紋背景

.cont{width:500px;height:200px;background:linear-gradient(45deg,#78C9DB 50%,#0acf00 50%);background-size:30px 30px;}

3. 草地背景

.cont{width:500px;height:200px;background:linear-gradient(-45deg,#0acf00 50%,#78C9DB 50%);background-size:30px 100%;}

4. 斜條紋背景

.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.單色斜條紋背景(利用透明度及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. 格子衫背景

.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.波點背景

.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.棋盤背景

.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;}

相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!

推薦閱讀:

CSS3的滑鼠移入圖片動態提示效果

css中sticker-footer布局如何使用

相關文章

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.