用html实现一个手风琴相册设计

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>手风琴相册设计</title>
    <link rel="stylesheet" href="./style.css">
</head>
<body>
<h1>Accordion Gallery</h1>
<div class="accordion">
  <!-- 在这里我们需要复制5个一样的代码,并修改内容 -->
  <ul>
    <li tabindex="1">
      <div>
        <a href="#">
          <h2>Bagel</h2>
          <p>The harder the crust is baked, the stronger the flavor and texture of the bread inside.</p>
        </a>
      </div>
    </li>

    <li tabindex="2">
      <div>
        <a href="#">
         <h2>Cup Cake</h2>
         <p>Cupcake is a dessert.</p>
        </a>
      </div>
    </li>

    <li tabindex="3">
      <div>
        <a href="#">
          <h2>Chocolate Cake</h2>
          <p>It is commonly used in birthday parties and weddings and is one of the common desserts.</p>
        </a>
      </div>
    </li>

    <li tabindex="4">
      <div>
        <a href="#">
          <h2>Light Food</h2>
          <p>The cooking method of food materials is simple, and the original nutrition and taste of food materials are retained.</p>
        </a>
      </div>
    </li>

    <li tabindex="5">
      <div>
        <a href="#">
          <h2>Sashimi</h2>
          <p>Sashimi refers to raw fish and other things, dipped in seasoning directly edible fish dishes.</p>
        </a>
      </div>
    </li>

    <li tabindex="6">
      <div>
        <a href="#">
          <h2>Xaman Beer</h2>
          <p>Guatemalan handcrafted Xaman beer bottle.</p>
        </a>
      </div>
    </li>
  </ul>
</div>
<p class="about">
  By <a href="https://Lavender-z.github.io/">橘子</a>
</p>
</body>
</html>
@import url(https://fonts.googleapis.com/css?family=Open+Sans);
@import url(https://fonts.googleapis.com/css?family=Montserrat:700);

h1 {
  text-align: center;
  font-family: Montserrat, sans-serif;
  color: #333;
}

.accordion {
  width: 100%;
  max-width: 1080px;
  height: 250px;
  overflow: hidden;
  margin: 50px auto;
}

.accordion ul {
  width: 100%;
  display: table;
  table-layout: fixed;
  margin: 0;
  padding: 0;
}

.accordion ul li {
  display: table-cell;
  vertical-align: bottom;
  position: relative;
  width: 16.666%;
  height: 250px;
  background-repeat: no-repeat;
  background-position: center center;
  transition: all 500ms ease;
}

.accordion ul li div {
  display: block;
  overflow: hidden;
  width: 100%;
}

.accordion ul li div a {
  display: block;
  height: 250px;
  width: 100%;
  position: relative;
  z-index: 3;
  padding: 15px 20px;
  box-sizing: border-box;
  color: #fff;
  text-decoration: none;
  font-family: Open Sans, sans-serif;
  transition: all 200ms ease;
}

.accordion ul li div a * {
  opacity: 0;
  margin: 0;
  width: 100%;
  text-overflow: ellipsis;
  position: relative;
  z-index: 5;
  white-space: nowrap;
  overflow: hidden;
  -webkit-transform: translateX(-20px);
  transform: translateX(-20px);
  -webkit-transition: all 400ms ease;
  transition: all 400ms ease;
}

.accordion ul li div a h2 {
  font-family: Montserrat, sans-serif;
  text-overflow: clip;
  font-size: 24px;
  text-transform: uppercase;
  margin-bottom: 2px;
  top: 160px;
}

.accordion ul li div a p {
  top: 160px;
  font-size: 13.5px;
}

.accordion ul li:nth-child(1) {
  background-image: url("https://source.unsplash.com/uYyLWm7V-9U");
}

.accordion ul li:nth-child(2) {
  background-image: url("https://source.unsplash.com/LD4KsgYUjxI");
}
.accordion ul li:nth-child(3) {
  background-image: url("https://source.unsplash.com/MQFNx9pVPRQ");
}

.accordion ul li:nth-child(4) {
  background-image: url("https://source.unsplash.com/7gM1R2yLfXk");
}

.accordion ul li:nth-child(5) {
  background-image: url("https://source.unsplash.com/jso_yKod6-c");
}

.accordion ul li:nth-child(6) {
  background-image: url("https://source.unsplash.com/46vZtdZhWAs");
}

.accordion ul:hover li, .accordion ul:focus-within li {
  width: 8%;
}

.accordion ul li:focus {
  outline: none;
}

.accordion ul:hover li:hover,
.accordion ul li:focus, .accordion ul:focus-within li:focus {
  width: 60%;
}

.accordion ul:hover li:hover a,
.accordion ul li:focus a, .accordion ul:focus-within li:focus a {
  background: rgba(0, 0, 0, 0.4);
}

.accordion ul:hover li:hover a *,
.accordion ul li:focus a *, .accordion ul:focus-within li:focus a * {
  opacity: 1;
  -webkit-transform: translateX(0);
  transform: translateX(0);
}

.accordion ul:hover li {
  width: 8% !important;
}

.accordion ul:hover li a * {
  opacity: 0 !important;
}

.accordion ul:hover li:hover {
  width: 60% !important;
}

.accordion ul:hover li:hover a {
  background: rgba(0, 0, 0, 0.4);
}

.accordion ul:hover li:hover a * {
  opacity: 1 !important;
  -webkit-transform: translateX(0);
  transform: translateX(0);
}

@media screen and (max-width: 600px) {
  body {
    margin: 0;
  }

  .accordion {
    height: auto;
  }

  .accordion ul li, .accordion ul li:hover, .accordion ul:hover li, .accordion ul:hover li:hover {
    position: relative;
    display: table;
    table-layout: fixed;
    width: 100%;
    -webkit-transition: none;
    transition: none;
  }
}

.about {
  text-align: center;
  font-family: "Open Sans", sans-serif;
  font-size: 12px;
  color: #666;
}

.about a {
  color: rgb(144, 144, 148);
  text-decoration: none;
}

.about a:hover {
  text-decoration: underline;
}

相关推荐

  1. 纯js+css实现手风琴

    2024-03-31 10:32:02       58 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-31 10:32:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-31 10:32:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-31 10:32:02       87 阅读
  4. Python语言-面向对象

    2024-03-31 10:32:02       96 阅读

热门阅读

  1. 有线电视网 题解

    2024-03-31 10:32:02       39 阅读
  2. 蓝桥杯算法题-发现环

    2024-03-31 10:32:02       43 阅读
  3. Unity WebRequest 变得简单

    2024-03-31 10:32:02       33 阅读
  4. Nginx入门--初识Nginx的架构

    2024-03-31 10:32:02       40 阅读
  5. 1688中国站按关键字搜索工厂数据 API

    2024-03-31 10:32:02       31 阅读
  6. B/S架构

    B/S架构

    2024-03-31 10:32:02      31 阅读
  7. 把CIFAR-10数据集分类保存成图片

    2024-03-31 10:32:02       33 阅读
  8. 如何系统地学习Python(四)标准库(二)

    2024-03-31 10:32:02       38 阅读
  9. 如何提高账号安全——密码的秘密

    2024-03-31 10:32:02       32 阅读
  10. 汽车电子行业知识:汽车电子领域包含哪些技术

    2024-03-31 10:32:02       32 阅读
  11. Centos 7 安装 Node.js v16.13.1

    2024-03-31 10:32:02       43 阅读
  12. 深入了解Vue中slot的应用

    2024-03-31 10:32:02       33 阅读
  13. kvm虚拟机迁移--来自gpt

    2024-03-31 10:32:02       31 阅读
  14. 工作总结5

    2024-03-31 10:32:02       33 阅读