div+css利用has实现可折叠相册效果代码

代码语言:html

所属分类:画廊相册

代码描述:div+css利用has实现可折叠相册效果代码

代码标签: div css has 折叠 相册

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
 
<meta charset="UTF-8">

 
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Della+Respira&family=Golos+Text:wght@400..900&display=swap" rel="stylesheet">
 
 
 
<style>
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 40px;
  width: 100vw;
  min-height: 100vh;
  background-color: black;
  font: normal normal 400 12pt / 2cap "Golos Text", sans-serif;
  color: white;
  overflow-x: hidden;
}

article {
  width: 100%;
  max-width: 1265px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  margin: 50px 0;
}

figure {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: space-between;
  margin: 0 0 30px 0;
}

figure figcaption {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
}

figure figcaption h1 {
  font: normal normal 400 240% / 1.5cap "Della Respira", serif;
  padding: 0 0 10px 0;
  margin: 0 0 20px 0;
  border-bottom: 1px solid #333;
  text-wrap: balance;
}

figure figcaption p {
  color: #bbb;
  padding-left: 30px;
  margin: 0;
  border-left: 10px solid;
  border-image: repeating-linear-gradient(
      43deg,
      white,
      white 4px,
      transparent 5px,
      transparent 9px,
      white 10px
    )
    10;
  text-wrap: pretty;
}

figure figcaption p span:last-of-type {
  display: none;
}

button {
  font: normal normal 400 12pt / 2cap "Golos Text", sans-serif;
  width: 200px;
  height: 50px;
  background-color: transparent;
  border: 1px solid #666;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

button::after {
  position: absolute;
  right: 100%;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: #ccc;
  content: "";
  z-index: -1;
  transition: all 0.3s ease;
}

button:hover::after {
  right: 0;
  transition: all 0.3s ease;
}

button input {
  display: none;
}

button label {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

button:hover label {
  color: black;
  transition: all 0.3s ease;
}

button label span {
  display: none;
}

button:not(:has(input:checked)) label span:first-of-type {
  display: initial;
}

button:has(input:checked) label span:last-of-type {
  display: initial;
}
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0