蘋果風格的底線

來源:互聯網
上載者:User

今天研究一個利用text-shadow和:after偽對象做成的蘋果風格的底線效果。


線上研究點這裡,下載收藏點這裡。

好啦,開工啦,先看html了

<span class="underlined">everybody go go go!</span>
CSS重點,我們用到了google web font,我們使用了上一篇文章裡介紹的google web font sass mixin。

@mixin gwf($fonts) {    $url: "http://fonts.googleapis.com/css?family=";    $nb: 0;        @each $font-name in $fonts {      $nb: $nb + 1;      $nb-word: 0;            @each $word in $font-name {        $nb-word: $nb-word + 1;        $url: $url + $word;                @if $nb-word < length($font-name) {          $url: $url + "+";         }       }            @if $nb < length($fonts) {         $url: $url + "|";       }    }        @import url(#{$url});  }  $fonts: Condiment, The Girl Next Door,Nothing You Could Do;  @include gwf($fonts); 
然後,就是正章啦

/* 設定字型顏色,背景顏色 */body {  background-color: #32a5fc;  color: #fff;}/* 設定字型,注意我們要把底線放到字型下面,所以需要position:absolute; */span {  position: absolute;  margin:100px;    font-family: Condiment;   font-size: 60px;  font-weight: 300;}/* 設定陰影,相當於描邊文字 */.underlined {  text-shadow:    -5px 0 0 #32a5fc,    5px 0 0 #32a5fc,    0 -5px 0 #32a5fc,    0 5px 0 #32a5fc;}/* 底線 */.underlined:after {  z-index: -1;  position: absolute;  bottom: -1px;  left: 0;  content: "";  width: 100%;  height: 2px;  background-color: #fff;}
完工。

---------------------------------------------------------------

前端開發whqet,關注web前端開發技術,分享網頁相關資源。
---------------------------------------------------------------

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.