如何创建:响应式定价表

学习如何使用 CSS 创建响应式定价表。

  • Basic
  • $ 9.99 / year
  • 10GB Storage
  • 10 Emails
  • 10 Domains
  • 1GB Bandwidth
  • Sign Up
  • Pro
  • $ 24.99 / year
  • 25GB Storage
  • 25 Emails
  • 25 Domains
  • 2GB Bandwidth
  • Sign Up
  • Premium
  • $ 49.99 / year
  • 50GB Storage
  • 50 Emails
  • 50 Domains
  • 5GB Bandwidth
  • Sign Up

自分で試してみる

如何创建响应式定价表

第1步 - 添加 HTML:

<div class="columns">
  <ul class="price">
    <li class="header">Basic</li>
    <li class="grey">$ 9.99 / year</li>
    <li>10GB Storage</li>
    <li>10 Emails</li>
    <li>10 Domains</li>
    <li>1GB Bandwidth</li>
    <li class="grey"><a href="#" class="button">Sign Up</a></li>
  </ul>
</div>

第2步 - CSSを追加:

* {
  box-sizing: border-box;
}
/* 三个等宽的列 */
.columns {
  float: left;
  width: 33.3%;
  padding: 8px;
}
/* リストのスタイルを設定 */
.price {
  list-style-type: none;
  border: 1px solid #eee;
  margin: 0;
  padding: 0;
  -webkit-transition: 0.3s;
  transition: 0.3s;
}
/* マウスオーバー時の影を追加 */
.price:hover {
  box-shadow: 0 8px 12px 0 rgba(0,0,0,0.2)
}
/* 定価表頭 */
.price .header {
  background-color: #111;
  color: white;
  font-size: 25px;
}
/* リスト項目 */
.price li {
  border-bottom: 1px solid #eee;
  padding: 20px;
  text-align: center;
}
/* 色リスト項目 */
.price .grey {
  background-color: #eee;
  font-size: 20px;
}
/* "Sign Up" ボタン */
.button {
  background-color: #04AA6D;
  border: none;
  color: white;
  padding: 10px 25px;
  text-align: center;
  text-decoration: none;
  font-size: 18px;
}
/* スクリーン幅が600px未満の時、三列の幅を100%に変更します(小さいスクリーン上で重ね合わせるため) */
@media only screen and (max-width: 600px) {
  .columns {
    width: 100%;
  }
}

自分で試してみる