Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!--Main Header-->
<header>
  <a href="#" class="navbar-brand">毛小孩星球</a>
  <input type="checkbox" class="navbar-toggle" id="navbar-toggle">
  <label for="navbar-toggle" class="navbar-toggle-label">
    <span class="hamburger"></span>
  </label>
  <nav class="nav">
    <ul class="nav-list">
      <li class="nav-item"><a class="nav-link" href="#activity">近期活動</a></li>
      <li class="nav-item"><a class="nav-link" href="#album">狗兒相片</a></li>
      <li class="nav-item"><a class="nav-link" href="#adoption">領養資訊</a></li>
    </ul>
  </nav>
</header>

<!-- activity -->
<section id="activity" class="activity">
  <div class="container">
    <div class="banner-wrapper">
      <div class="main-banner background-image">
        <h1 class="banner-title">帶毛小孩回家吧</h1>
        <p class="banner-description">Bring them back home</p>
        <a href="#adoption" class="action">領養去</a>
      </div>
      <div class="sub-banner sub-banner-left background-image">
        <h3 class="banner-title">捐款送玩偶</h3>
        <p class="banner-description">NTD 100</p>
        <a href="#" class="action">捐款</a>
      </div>
      <div class="sub-banner sub-banner-right background-image">
        <h3 class="banner-title">捐款送狗骨頭</h3>
        <p class="banner-description">NTD 300</p>
        <a href="#" class="action">捐款</a>
      </div>
    </div>
  </div>
</section>

 <!--Album-->
  <section id="album">
    <div class="container">
      <div class="album-wrapper grid-container--fit">
        <div class="card">
          <img
            src="https://images.unsplash.com/photo-1511382686815-a9a670f0a512?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=968&q=80"
            alt=""
            class="card-img"
          />
          <div class="card-text">
            <h3 class="card-title">藍哥</h3>
            <p class="card-description">7 歲</p>
          </div>
        </div>
        <div class="card">
          <img
            src="https://images.unsplash.com/photo-1554224311-beee415c201f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=975&q=80"
            alt=""
            class="card-img"
          />
          <div class="card-text">
            <h3 class="card-title">小黑</h3>
            <p class="card-description">2 歲</p>
          </div>
        </div>
        <div class="card">
          <img
            src="https://images.pexels.com/photos/2737393/pexels-photo-2737393.jpeg?auto=compress&cs=tinysrgb&h=650&w=940"
            alt=""
            class="card-img"
          />
          <div class="card-text">
            <h3 class="card-title">花花</h3>
            <p class="card-description">4 歲</p>
          </div>
        </div>
        <div class="card">
          <img
            src="https://images.pexels.com/photos/551628/pexels-photo-551628.jpeg?auto=compress&cs=tinysrgb&h=650&w=940"
            alt=""
            class="card-img"
          />
          <div class="card-text">
            <h3 class="card-title">皮克</h3>
            <p class="card-description">3 歲</p>
          </div>
        </div>
        <div class="card">
          <img
            src="https://images.pexels.com/photos/1490908/pexels-photo-1490908.jpeg?auto=compress&cs=tinysrgb&h=650&w=940"
            alt=""
            class="card-img"
          />
          <div class="card-text">
            <h3 class="card-title">哈金</h3>
            <p class="card-description">6 歲</p>
          </div>
        </div>
        <div class="card">
          <img
            src="https://images.pexels.com/photos/164186/pexels-photo-164186.jpeg?auto=compress&cs=tinysrgb&h=650&w=940"
            alt=""
            class="card-img"
          />
          <div class="card-text">
            <h3 class="card-title">大小姐</h3>
            <p class="card-description">5 歲</p>
          </div>
        </div>
        <div class="card">
          <img
            src="https://images.pexels.com/photos/545063/pexels-photo-545063.jpeg?auto=compress&cs=tinysrgb&h=650&w=940"
            alt=""
            class="card-img"
          />
          <div class="card-text">
            <h3 class="card-title">公主</h3>
            <p class="card-description">2 歲</p>
          </div>
        </div>
        <div class="card">
          <img
            src="https://images.pexels.com/photos/1564506/pexels-photo-1564506.jpeg?auto=compress&cs=tinysrgb&h=650&w=940"
            alt=""
            class="card-img"
          />
          <div class="card-text">
            <h3 class="card-title">獨角獸</h3>
            <p class="card-description">2 歲</p>
          </div>
        </div>
        <div class="card">
          <img
            src="https://images.unsplash.com/photo-1446231855385-1d4b0f025248?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80"
            alt=""
            class="card-img"
          />
          <div class="card-text">
            <h3 class="card-title">阿獅</h3>
            <p class="card-description">3 歲</p>
          </div>
        </div>
        <div class="card">
          <img
            src="https://images.unsplash.com/photo-1455526050980-d3e7b9b789a4?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=625&q=80"
            alt=""
            class="card-img"
          />
          <div class="card-text">
            <h3 class="card-title">辛巴</h3>
            <p class="card-description">2 歲</p>
          </div>
        </div>
        <div class="card">
          <img
            src="https://images.unsplash.com/photo-1446730853965-62433e868929?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80"
            alt=""
            class="card-img"
          />
          <div class="card-text">
            <h3 class="card-title">豆皮</h3>
            <p class="card-description">2 歲</p>
          </div>
        </div>
        <div class="card">
          <img
            src="https://images.unsplash.com/photo-1513757271804-385fb022e70a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80"
            alt=""
            class="card-img"
          />
          <div class="card-text">
            <h3 class="card-title">阿瓜</h3>
            <p class="card-description">2 歲</p>
          </div>
        </div>
      </div>
    </div>
  </section>
              
            
!

CSS

              
                /* 載入字型 */
@import url("https://fonts.googleapis.com/css?family=Noto+Sans+TC:400,700&display=swap&subset=chinese-traditional");

*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  height: 100%;
}
body {
  background-color: #f6f7f8;
  font-family: "Noto Sans TC", sans-serif;
  font-size: 1rem;
  line-height: 1.4;
  margin: 0;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0;
  line-height: 0.9;
}

p {
  margin: 0;
}

ul,
li {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

a {
  text-decoration: none;
}

.container {
  width: 85%;
  margin: 0 auto 3rem auto;
}

/*共用按鈕樣式*/
.action {
  color: white;
  background: #39bae6;
  border-radius: 0.25rem;
  display: inline-block;
  font-size: 1rem;
  padding: 0.25rem 1rem;
  transition: all 0.1s linear;
}

.action:hover {
  background: #267c99;
  -webkit-box-shadow: 0px 1px 5px 0px rgba(87, 87, 87, 1);
  -moz-box-shadow: 0px 1px 5px 0px rgba(87, 87, 87, 1);
  box-shadow: 0px 1px 5px 0px rgba(87, 87, 87, 1);
}

.background-image {
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

/*Main Header*/
header {
  position: fixed;
  width: 100%;
  height: 60px;
  z-index: 999;
  text-align: center;
  background: #ffffff;
  -webkit-box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.1);
  -moz-box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.1);
  box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.1);
}

.nav {
  position: absolute;
  top: 100%;
  width: 100%;
  background: #ffffff;
  transform: scale(1, 0);
  transform-origin: top;
  transition: transform 0.3s ease-out;
}

.navbar-brand {
  color: #267b98;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 60px;
}

.nav-item {
  margin: 1.4rem 0;
  opacity: 0;
}

.nav-link {
  color: #267b98;
}

/* checkbox */
.navbar-toggle:checked {
  margin-left: 15px;
} /* 右移15px */
.navbar-toggle:checked ~ .nav {
  transform: scale(1, 1);
}
.navbar-toggle:checked ~ .nav .nav-item {
  opacity: 1;
  transition: opacity 0.2s ease-out 0.15s;
}

.navbar-toggle-label {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 7.5%;
  display: flex;
  align-items: center;
}

.hamburger,
.hamburger::before,
.hamburger::after {
  width: 30px;
  height: 3px;
  background: #267b98;
}
.hamburger::before,
.hamburger::after {
  position: absolute;
  left: 0;
  content: "";
}
.hamburger {
  position: relative;
}
.hamburger::before {
  top: 8px;
}
.hamburger::after {
  bottom: 8px;
}
.navbar-toggle {
  visibility: hidden;
  position: absolute;
}
.banner-wrapper {
  padding-top: 92px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 250px);
  grid-template-areas:
    "main main main main"
    "left left right right";
  grid-gap: 0.5rem;
}

.main-banner,
.sub-banner {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  -webkit-box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.08);
  -moz-box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.08);
  box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.08);
}

.main-banner {
  grid-area: main;
  background-image: url("https://images.unsplash.com/photo-1520087619250-584c0cbd35e8?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1285&q=80");
}
.sub-banner-left {
  grid-area: left;
  background-image: url("https://images.unsplash.com/photo-1569809317138-8d2ff6060c4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80");
}
.sub-banner-right {
  grid-area: right;
  background-image: url("https://images.unsplash.com/photo-1535294435445-d7249524ef2e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80");
}

/* 文字內容和按鈕樣式設定 */
.banner-title {
  margin-bottom: 0.4rem;
}

.main-banner .banner-title {
  font-size: 2rem;
  color: #1a5366;
}
.banner-description {
  margin-bottom: 1rem;
  font-weight: 600;
}
.main-banner .banner-description {
  color: #267b98;
  font-size: 1rem;
}
.sub-banner .action {
  font-size: 1rem;
  padding: 0.25rem 1rem;
}
.sub-banner .banner-title,
.sub-banner .banner-description {
  color: #fff;
  font-size: 1.2rem;
  font-weight: 400;
  letter-spacing: 1px;
}

/* Album */
.album-wrapper {
  position: relative;
  display: grid;
  grid-template-columns: repeat( auto-fit, minmax(300px, 1fr) );
  grid-template-rows: repeat(3, 300px);
  grid-gap: 1rem;
}
.card {
  position: relative;
  transition: opacity .5s;
}
img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-text {
  z-index: 1;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity;
  color: #FFFFFF;
}
.card:hover .card-text{
  opacity: 1;
}
.card:hover {
  opacity: 0.5;
}
.card::before {
  position: absolute;
  content: "";
  height: 95%;
  width: 86%;
  left: 7%;
  top: 3%;
  border-left: 2px solid white;
  border-right: 2px solid white;
  opacity: 0;
  transform: scale(1,0);
  transition: transform ease-out .5s;
}
.card::after {
  position: absolute;
  content: "";
  width: 92%;
  height: 86%;
  left: 5%;
  top: 7%;
  border-top: 2px solid white;
  border-bottom: 2px solid white;
  opacity: 0;
  transform: scale(0,1);
  transition: transform ease-out .5s;
}
.card:hover::before, .card:hover::after {
  opacity: 1;
  transform: scale(1,1);
}

/* 電腦尺寸 */
@media screen and (min-width: 768px) {
  .action {
    font-size: 1.2rem;
    padding: 0.75rem 2rem;
  }
  /*   導覽列的手機樣式改為電腦樣式 */
  .navbar-brand {
    grid-column: 2 / 3;
  }
  .nav {
    all: unset;
    grid-column: 3 / 4;
  }
  .navbar-toggle-label {
    display: none;
  }
  .nav-item {
    margin: 0;
    opacity: 1;
  }
  header {
    display: grid;
    grid-template-columns: 1fr auto minmax(600px, 3fr) 1fr;
  }

  .nav-list {
    height: 100%;
    display: grid;
    grid-auto-flow: column;
    align-items: center;
    justify-content: end;
    grid-gap: 2rem;
  }

  /* Banner的部分 */
  .banner-wrapper {
    grid-template-areas:
      "main main main left"
      "main main main right";
    grid-gap: 1.5rem;
  }
  .main-banner {
    align-items: flex-start;
    justify-content: center;
  }
  .main-banner .banner-title {
    font-size: 4rem;
  }
  .main-banner .banner-description {
    font-size: 2rem;
  }
  .sub-banner .banner-title {
    font-size: 2rem;
  }
  .sub-banner .action {
    font-size: 1.2rem;
  }

}

              
            
!

JS

              
                
              
            
!
999px

Console