Web_Basic
  • Introduction
  • Web Component
  • HTML basic
  • CSS basic
    • Inline element 與 Block element
    • 實用CSS 技巧
    • CSS Grid 教學
  • CSS Advance
    • Adobe spectrum
    • CSS Tricks
    • Contain block
    • OOCSS、SMACSS、BEM、SEM、BIO
    • z-index
    • Flexbox教學
    • 使用Materialize css
    • 使用Semantic UI
    • 使用Bootstrap
    • Ant design
    • Less
    • Animation
    • 簡單的特效
    • SCSS
  • Javascript basic
  • 開始寫一個網站前
    • 寫一個靜態網站2
    • 寫一個靜態網站
  • 部屬到github pages
  • 做一個OX小遊戲
  • 做一個貪食蛇小遊戲
  • canvas
  • Regexp
  • SVG
  • Sublime快捷鍵
  • Deploy Blog 使用 Hexo
  • 域名設定
    • 註冊域名信箱
      • 使用AWS SES
      • mailgun
    • subdomain,清除DNS快取
  • 使用cloudflare
  • 使用VNC server
  • SEO
    • Sitemap
    • search console
  • 遠端連線
  • HTML LiveReload
  • ngrok 與 local tunnel
  • Service worker 與 Cache
  • Zeplin 搭配 Sketch
  • 測試 IE 網頁相容性
  • 網站產生器
Powered by GitBook
On this page
  • 改變字型
  • 簡單效果

Was this helpful?

  1. CSS Advance

簡單的特效

PreviousAnimationNextSCSS

Last updated 5 years ago

Was this helpful?

改變字型

在這之前,介紹一個字型的網站

如何使用?

1.加入<link href='字型網址' rel='stylesheet' type='text/css'>

2.font-family: '字型名稱

簡單效果

1.淡入

新增一個HTML檔案,加入

<!DOCTYPE html>
<html>
<head>

    <link href='http://fonts.googleapis.com/css?family=Lato:900' rel='stylesheet' type='text/css'>

    <style type="text/css">

        body > div
        {

            margin:121px 149px;

            width:483px;
            height:298px;

            background:#676470;
            color:#fff;

            font-family:Lato;
            font-weight:900;
            font-size:3.4em;

            text-align:center;
            line-height:298px;

            transition:all 0.3s;

        }

        .fade
        {
            opacity:0.5;
        }
        .fade:hover
        {
            opacity:1;
        }

    </style>
</head>
<body>

    <div class="fade">Fade in</div>

</body>
</html>

2.淡出

        .fade
        {
            opacity:1;
        }
        .fade:hover
        {
            opacity:0.5;
        }

3.滑鼠滑入時更改顏色

<!DOCTYPE html>
<html>
<head>

    <link href='http://fonts.googleapis.com/css?family=Lato:900' rel='stylesheet' type='text/css'>

    <style type="text/css">

        body > div
        {

            margin:121px 149px;

            width:483px;
            height:298px;

            background:#676470;
            color:#fff;

            font-family:Lato;
            font-weight:900;
            font-size:3.4em;

            text-align:center;
            line-height:298px;

            transition:all 0.3s ease;

        }

        .color:hover
        {
            background:#53a7ea;
        }

    </style>
</head>
<body>

    <div class="color">Change Color</div>

</body>
</html>

4.放大

 .color:hover
        {
            transform: scale(1.3);
            background:#53a7ea;
        }

5.縮小

       .color:hover
        {
            transform: scale(0.3);
            background:#53a7ea;
        }

6.旋轉縮小

        .color:hover
        {

            transform: scale(0.3) rotateZ(-30deg);
            background:#53a7ea;
        }

7.變換外框形狀

        .color:hover
        {

            border-radius:50%;
            background:#53a7ea;
        }

8.重疊陰影效果

        .color:hover
        {

                box-shadow:
                10px 10px #53a7ea,
                20px 20px #53a7ea,
                30px 30px #53a7ea;

        transform: translateX(-30px);
        }

9.震動效果

  /* 定義關鍵影格 */
 @keyframes swing
{
    15%
    {
        -webkit-transform: translateX(5px);
        transform: translateX(5px);
    }
    30%
    {
        -webkit-transform: translateX(-5px);
        transform: translateX(-5px);
    }
    50%
    {
        -webkit-transform: translateX(3px);
        transform: translateX(3px);
    }
    65%
    {
        -webkit-transform: translateX(-3px);
        transform: translateX(-3px);
    }
    80%
    {
        -webkit-transform: translateX(2px);
        transform: translateX(2px);
    }
    100%
    {
        -webkit-transform: translateX(0);
        transform: translateX(0);
    }
}

/*套用*/
        .color:hover
        {

      animation: swing 1s ease;
        }

10.往內的邊框

        .color:hover
        {

  box-shadow: inset 0 0 0 25px #53a7ea;
        }

11.視差捲動

<!DOCTYPE html>
<html>
<head>

<body>
<style>
   .demo {
    perspective: 1px; padding: 0; height: 800px; height: calc(100vh - 300px); overflow: auto;
}
.box {
    height: 1280px;
    transform-style: preserve-3d;
    position: relative;
}
.iphone {
    position: absolute; left: 50%;
    transform: translate3D(-50%, -120px, -10px) scale(8);
}
</style>
<div class="demo">
    <div class="box">
        <img src="001.jpg" class="iphone">
        <i class="smile"><img style="position:absolute;top:620px;left:320px; "src="0112.png"/></i><i class="flower"></i><i class="music"></i><i class="pdf"></i>
    </div>
</div>
</body>
</html>

perspective為人們看元素的距離(數字越大越近看)

translateZ為Z軸的坐標

scale放大元素

(想像坐在車上時觀看窗外月亮,沒有移動,但窗外樹叢卻移動很快,同樣道理)

解說:

https://www.google.com/fonts/
http://codepen.io/EasonWang01/pen/VaQYmW