爬行的蜗牛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: golang Linux PHP
查看: 90|回复: 0

HTML+CSS实现简易的价格表“新手存”!!附源码!!

[复制链接]

152

主题

48

回帖

1137

积分

管理员

积分
1137
发表于 2024-12-22 20:21:58 | 显示全部楼层 |阅读模式
640.gif
HTML部分
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <meta charset="utf-8" />
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6.     <link rel="stylesheet" href="css/style.css"/>
  7.     <title>Document</title>
  8.   </head>
  9.   <body>
  10.     <div class="price-table">
  11.       <div class="price-card">
  12.         <h2 class="price-card__title">Basic</h2>
  13.         <div class="price-card__ribbon">
  14.           <span class="price-card__ribbon-text"
  15.           >¥3.</span class="price-card__ribbon-text-highlight">99</span>
  16.           </span>
  17.           </div>
  18.           <div class="price-card__info">
  19.             <p> 1 User</p>
  20.             <p> 1 Project</p>
  21.             <p> 2GB Disk Space</p>
  22.             <p> Standard Support</p>
  23.         </div>
  24.       </div>
  25.       <div class="price-card price-card--highlight">
  26.         <h2 class="price-card__title">Advanced</h2>
  27.         <div class="price-card__ribbon">
  28.           <span class="price-card__ribbon-text"
  29.           >¥8.<span class="price-card__ribbon-text-highlight">99</span>
  30.           </span>
  31.         </div>
  32.         <div class="price-card__info">
  33.           <p>25 Users</p>
  34.           <p>Unlimited Projects</p>
  35.           <p>10GB Disk Space</p>
  36.           <p>Standard Support</p>
  37.         </div>
  38.       </div>
  39.       
  40.       <div class="price-card">
  41.         <h2 class="price-card__title">Premium</h2>
  42.         <div class="price-card__ribbon">
  43.           <span class="price-card__ribbon-text"></span>
  44.           ¥15.<span class="price-card__ribbon-text-highlight"
  45.           >99</span
  46.           ></span
  47.           >
  48.         </div>
  49.         <div class="price-card__info">
  50.           <p>100 Users</p>
  51.           <p>Unlimited Projects</p>
  52.           <p>50GB Disk Space</p>
  53.           <p>Premium Support</p>
  54.         </div>
  55.       </div>
  56.     </div>
  57.   </body>
  58. </html>
复制代码
CSS部分
  1. *{
  2.   margin: 0;
  3.   padding: 0;
  4.   box-sizing: border-box;
  5. }

  6. :root {
  7.   --c-ribbon: #2f2f2f;
  8.   --c-ribbon-shadow: #666;
  9.   --c-ribbon-text: #efefef;
  10.   --c-title :#2f2f2f;
  11. }

  12. body {
  13.   display: flex;
  14.   justify-content: center;
  15.   align-items: center;
  16.   min-height: 100vh;
  17.   background: #ddd;
  18. }

  19. .price-table {
  20.   position: relative;
  21.   display: flex;
  22.   justify-content: center;
  23.   align-items: center;
  24.   user-select: none;
  25. }

  26. .price-card {
  27.   color: #555;
  28.   background-color: #fff;
  29.   width: 25%;
  30.   aspect-ratio: 9/14.5;
  31.   min-width: 12rem;
  32.   max-width: 15rem;
  33.   text-align: center;
  34.   margin: 0 2rem;
  35.   margin: 0.5rem 0 1rem;
  36.   box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2);
  37.   transition: 0.5s;
  38.   cursor: pointer;
  39. }

  40. .price-card:hover {
  41.   transform: translateY(-20px);
  42. }
  43. .price-card__ribbon {
  44.   position: relative;
  45.   padding: 2rem 1rem;
  46.   margin: 2rem --0.8rem 2rem;
  47.   background-color: var(--c-ribbon);
  48.   transform: skew(0, -10deg);
  49.   border-radius: 3px 0;
  50.   box-shadow: 0 2rem 1.2rem -2rem var(--c-ribbon-shadow);
  51. }

  52. .price-card__ribbon::before,
  53. .price-card__ribbon::after {
  54.   position: absolute;
  55.   content: "";
  56.   width: 0;
  57.   height: 0;
  58.   border-style: solid;
  59. }

  60. .price-card__ribbon::before {
  61.   border-width: 0 0.8rem 0.8rem 0;
  62.   border-color: transparent var(--c-ribbon-shadow) transparent transparent;
  63.   left: 0;
  64.   bottom: 0;
  65.   transform: translateY(100%);
  66. }

  67. .price-card__ribbon::after {
  68.   border-width: 0.8rem 0 0 0.8rem;
  69.   border-color: transparent transparent transparent var(--c-ribbon-shadow);
  70.   right: 0;
  71.   top: 0;
  72.   transform: translateY(-100%);
  73. }

  74. .price-card__ribbon-text {
  75.   color: var(--c-ribbon-text);
  76.   font-size: 2rem;
  77.   line-height: 1.4;
  78.   font-weight: 700;
  79.   display: block;
  80.   transform: skew(0, 10deg);
  81. }

  82. .price-card__ribbon-text-highlight {
  83.   color: yellow;
  84.   font-size: 0.5em;
  85. }

  86. .price-card__title {
  87.   color: var(--c-title);
  88. }

  89. .price-card--highlight {
  90.   --c-ribbon: #f94289;
  91.   --c-ribbon-text: #fff;
  92.   --c-ribbon-shadow: #ff619b;
  93.   --c-title: #f94289;
  94.   box-shadow: 0 0 3rem -1.5rem rgba(0, 0, 0, 0.5);
  95. }

  96. .price-card__info {
  97.   display: flex;
  98.   flex-direction: column;
  99.   gap: 10px;
  100. }

  101. .price-card__info p {
  102.   font-size: 0.4em;
  103. }
复制代码

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表