CSS 學習紀錄(1)-Hello world

頁面設計

<link href="https://afeld.github.io/emoji-css/emoji.css" rel="stylesheet">

<body>
  <div class="container">
    <div class="speech_bubble">
      <h1 class="hello">Hello World <i class="em-svg em-hand"></i></h1>
    </div>
  </div>
</body>
成果

說明

  • @import
    • @import 指令最初的用意,是為了能夠針對不同的瀏覽器而運用不同的樣式。 現在用 @import 的目的,最常是要加入多個 CSS 樣式。當多個 CSS 樣式被 @import 的方式加入,而不同 CSS 樣式互相有衝突時,後被加入的 CSS 樣式有優先的順位 
// 範例
@import url("fineprint.css") print;
@import url("bluish.css") projection, tv;
@import 'custom.css';
@import url("chrome://communicator/skin/");
@import "common.css" screen, projection;
@import url('landscape.css') screen and (orientation:landscape);

CSS 設計

@import url("https://fonts.googleapis.com/css?family=Pacifico");  // 引入Google 字形
  • speech_bubble 對話外框
// Speech bubble style
.speech_bubble {
  width: 625px;
  height: 220px;
  background: #fff;
  position: relative;
  margin: auto; 
  border: 10px solid #fff;
  @include border-radius(200px);
  @include animation(pop 2s ease-out);
  filter: drop-shadow(4px 7px 0px $shadow);
}

全文


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CodePen - Day 1: Hello CSS</title>
<style>
  @import url("https://fonts.googleapis.com/css?family=Pacifico");
body,
html {
  background: linear-gradient(to top, #da22ff, #9733ee);
  background-repeat: no-repeat;
  background-attachment: fixed;
  width: 100vw;
  height: 100vh;
}

.container {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.hello {
  font-family: "Pacifico", cursive;
  font-size: 70px;
  background-image: -webkit-linear-gradient(to top, #da22ff, #9733ee);
  background-image: -moz-linear-gradient(to top, #da22ff, #9733ee);
  background-image: -ms-linear-gradient(to top, #da22ff, #9733ee);
  background-image: -o-linear-gradient(to top, #da22ff, #9733ee);
  background-image: linear-gradient(to top, #da22ff, #9733ee);
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  text-align: center;
  opacity: 0;
  filter: drop-shadow(2px 7px 0px #e3e3e3);
  -moz-animation: hello 2s forwards;
  -webkit-animation: hello 2s forwards;
  animation: hello 2s forwards;
  -moz-animation-delay: 0.8s;
  -webkit-animation-delay: 0.8s;
  animation-delay: 0.8s;
}

.speech_bubble {
  width: 625px;
  height: 220px;
  background: #fff;
  position: relative;
  margin: auto;
  border: 10px solid #fff;
  -moz-border-radius: 200px;
  -webkit-border-radius: 200px;
  border-radius: 200px;
  -moz-animation: pop 2s ease-out;
  -webkit-animation: pop 2s ease-out;
  animation: pop 2s ease-out;
  filter: drop-shadow(4px 7px 0px #e3e3e3);
}

@-moz-keyframes pop {
  0% {
    width: 100px;
  }
  40% {
    width: 1000px;
  }
  80% {
    width: 600px;
  }
}
@-webkit-keyframes pop {
  0% {
    width: 100px;
  }
  40% {
    width: 1000px;
  }
  80% {
    width: 600px;
  }
}
@keyframes pop {
  0% {
    width: 100px;
  }
  40% {
    width: 1000px;
  }
  80% {
    width: 600px;
  }
}
@-moz-keyframes hello {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}
@-webkit-keyframes hello {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}
@keyframes hello {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}
.speech_bubble:after, .speech_bubble:before {
  width: 0;
  height: 0;
  border-left: 40px solid transparent;
  border-right: 40px solid transparent;
  border-top: 50px solid #fff;
  content: "";
  top: 210px;
  position: absolute;
  left: 100px;
  right: 0;
  margin: auto;
  -moz-animation: move 0.8s ease;
  -webkit-animation: move 0.8s ease;
  animation: move 0.8s ease;
}

.speech_bubble:before {
  top: 220px;
  border-top: 55px solid #fff;
  border-left: 44px solid transparent;
  border-right: 44px solid transparent;
}

@-moz-keyframes move {
  0% {
    top: 50px;
    left: -10px;
  }
  50% {
    left: 50px;
  }
  100% {
    left: 100px;
  }
}
@-webkit-keyframes move {
  0% {
    top: 50px;
    left: -10px;
  }
  50% {
    left: 50px;
  }
  100% {
    left: 100px;
  }
}
@keyframes move {
  0% {
    top: 50px;
    left: -10px;
  }
  50% {
    left: 50px;
  }
  100% {
    left: 100px;
  }
}
.em-hand {
  font-size: 48px;
  text-align: center;
  margin: 0.5em 0.5em 1em;
  -moz-animation: wave 0.3s alternate infinite;
  -webkit-animation: wave 0.3s alternate infinite;
  animation: wave 0.3s alternate infinite;
  -webkit-transform-origin: 50% 100%;
  -moz-transform-origin: 50% 100%;
  -ms-transform-origin: 50% 100%;
  transform-origin: 50% 100%;
}

@-moz-keyframes wave {
  0% {
    -webkit-transform: rotate(-30deg);
    -moz-transform: rotate(-30deg);
    -ms-transform: rotate(-30deg);
    transform: rotate(-30deg);
  }
  100% {
    -webkit-transform: rotate(10deg);
    -moz-transform: rotate(10deg);
    -ms-transform: rotate(10deg);
    transform: rotate(10deg);
  }
}
@-webkit-keyframes wave {
  0% {
    -webkit-transform: rotate(-30deg);
    -moz-transform: rotate(-30deg);
    -ms-transform: rotate(-30deg);
    transform: rotate(-30deg);
  }
  100% {
    -webkit-transform: rotate(10deg);
    -moz-transform: rotate(10deg);
    -ms-transform: rotate(10deg);
    transform: rotate(10deg);
  }
}
@keyframes wave {
  0% {
    -webkit-transform: rotate(-30deg);
    -moz-transform: rotate(-30deg);
    -ms-transform: rotate(-30deg);
    transform: rotate(-30deg);
  }
  100% {
    -webkit-transform: rotate(10deg);
    -moz-transform: rotate(10deg);
    -ms-transform: rotate(10deg);
    transform: rotate(10deg);
  }
}
</style>
</head>
<body translate="no">
<link href="https://afeld.github.io/emoji-css/emoji.css" rel="stylesheet">
<body>
<div class="container">
<div class="speech_bubble">
<h1 class="hello">Hello World <i class="em-svg em-hand"></i></h1>
</div>
</div>
</body>
</body>
</html>

使用工具

參考網站

相關文件