响应式价格表

创建于 2024-12-03 / 26
字体: [默认] [大] [更大]

了解如何使用 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;
}

/* Style the list */
.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;
}

/* Grey list item */
.price .grey {
  background-color: #eee;
  font-size: 20px;
}

/* The "Sign Up" button */
.button {
  background-color: #4CAF50;
  border: none;
  color: white;
  padding: 10px 25px;
  text-align: center;
  text-decoration: none;
  font-size: 18px;
}

/* 将三列的宽度更改为 100%
(在小屏幕上水平堆叠) */
@media only screen and (max-width: 600px) {
  .columns {
    width: 100%;
  }
} 亲自试一试 »

0 人点赞过