利用css3放射狀漸層做一張優惠券

來源:互聯網
上載者:User
這篇文章主要介紹了利用css3放射狀漸層做一張優惠券的樣本的相關資料,內容挺不錯的,現在分享給大家,也給大家做個參考。

在很多購物網站上都能看到優惠券,代金券,什麼什麼的券,但基本都是圖片直接放上去,那麼你有沒有想過css來做一個呢,反正我是這樣想過。那麼你怎麼做呢,切圖做背景平鋪邊緣,嗯,有這樣想過,如今css3技術這麼先進再用背景做平鋪是不是已經out了,那麼今天給大家介紹一個用css3放射狀漸層做的優惠券。

CSS3 放射狀漸層和線性漸層是很相似的,首先來看其文法:

-moz-radial-gradient([<bg-position> || <angle>,]? [<shape> || <size>,]? <color-stop>, <color-stop>[, <color-stop>]*);-webkit-radial-gradient([<bg-position> || <angle>,]? [<shape> || <size>,]? <color-stop>, <color-stop>[, <color-stop>]*);

除了你已經線上性漸層中看到的起始位置,方向和顏色,徑向梯度允許你指定漸層的形狀(圓形或橢圓形)和大小(最近端,最近角,最遠端,最遠角,包含或覆蓋 (closest-side, closest-corner, farthest-side, farthest-corner, contain or cover))。 顏色起止(Color stops):就像用線性漸層,你應該沿著漸層線定義漸層的起止顏色。

做優惠券最主要的代碼如下,就是這三句

background: radial-gradient(transparent 0, transparent 5px, #F39B00 5px);background-size: 15px 15px;background-position: 9px 3px;

不多解釋直接上代碼

優惠券

CSS代碼

這是公用樣式

.stamp {width: 387px;height: 140px;padding: 0 10px;position: relative;overflow: hidden;}.stamp:before {content: '';position: absolute;top:0;bottom:0;left:10px;right:10px;z-index: -1;}.stamp:after {content: '';position: absolute;left: 10px;top: 10px;right: 10px;bottom: 10px;box-shadow: 0 0 20px 1px rgba(0, 0, 0, 0.5);z-index: -2;}.stamp i{position: absolute;left: 20%;top: 45px;height: 190px;width: 390px;background-color: rgba(255,255,255,.15);transform: rotate(-30deg);}.stamp .par{float: left;padding: 16px 15px;width: 220px;border-right:2px dashed rgba(255,255,255,.3);text-align: left;}.stamp .par p{color:#fff;}.stamp .par span{font-size: 50px;color:#fff;margin-right: 5px;}.stamp .par .sign{font-size: 34px;}.stamp .par sub{position: relative;top:-5px;color:rgba(255,255,255,.8);}.stamp .copy{display: inline-block;padding:21px 14px;width:100px;vertical-align: text-bottom;font-size: 30px;color:rgb(255,255,255);}.stamp .copy p{font-size: 16px;margin-top: 15px;}.stamp01{background: #F39B00;background: radial-gradient(rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 5px, #F39B00 5px);background-size: 15px 15px;background-position: 9px 3px;}.stamp01:before{background-color:#F39B00;}.stamp02{background: #D24161;background: radial-gradient(transparent 0, transparent 5px, #D24161 5px);background-size: 15px 15px;background-position: 9px 3px;}.stamp02:before{background-color:#D24161;}.stamp03{background: #7EAB1E;background: radial-gradient(transparent 0, transparent 5px, #7EAB1E 5px);background-size: 15px 15px;background-position: 9px 3px;}.stamp03:before{background-color:#7EAB1E;}.stamp03 .copy{padding: 10px 6px 10px 12px;font-size: 24px;}.stamp03 .copy p{font-size: 14px;margin-top: 5px;margin-bottom: 8px;}.stamp03 .copy a{background-color:#fff;color:#333;font-size: 14px;text-decoration:none;padding:5px 10px;border-radius:3px;display: block;}.stamp04{width: 390px;background: #50ADD3;background: radial-gradient(rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 4px, #50ADD3 4px);background-size: 12px 8px;background-position: -5px 10px;}.stamp04:before{background-color:#50ADD3;left: 5px;right: 5px;}.stamp04 .copy{padding: 10px 6px 10px 12px;font-size: 24px;}.stamp04 .copy p{font-size: 14px;margin-top: 5px;margin-bottom: 8px;}.stamp04 .copy a{background-color:#fff;color:#333;font-size: 14px;text-decoration:none;padding:5px 10px;border-radius:3px;display: block;}

HTML代碼

<p class="stamp stamp01"><p class="par"><p>XXXXXX折扣店</p><sub class="sign">¥</sub><span>50.00</span><sub>優惠券</sub><p>訂單滿100.00元</p></p><p class="copy">副券<p>2015-08-13<br>2016-08-13</p></p><i></i></p><p class="stamp stamp02"><p class="par"><p>XXXXXX折扣店</p><sub class="sign">¥</sub><span>50.00</span><sub>優惠券</sub><p>訂單滿100.00元</p></p><p class="copy">副券<p>2015-08-13<br>2016-08-13</p></p><i></i></p><p class="stamp stamp03"><p class="par"><p>XXXXXX折扣店</p><sub class="sign">¥</sub><span>50.00</span><sub>優惠券</sub><p>訂單滿100.00元</p></p><p class="copy">副券<p>2015-08-13<br>2016-08-13</p><a href="#">立即使用</a></p><i></i></p><p class="stamp stamp04"><p class="par"><p>XXXXXX折扣店</p><sub class="sign">¥</sub><span>50.00</span><sub>優惠券</sub><p>訂單滿100.00元</p></p><p class="copy">副券<p>2015-08-13<br>2016-08-13</p><a href="#">立即使用</a></p><i></i></p>

PS:用這個方式還可以做郵票,不信你試試

以上就是本文的全部內容,希望對大家的學習有所協助,更多相關內容請關注topic.alibabacloud.com!

相關文章

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.