css布局实现产品列表搜索显示详情效果代码
代码语言:html
所属分类:布局界面
代码描述:css布局实现产品列表搜索显示详情效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Product List</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/normalize.min.css">
<style>
@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&display=swap");
:root {
--main-color: #fc302b;
--font: "Space Grotesk", sans-serif;
--border-color: #08090a;
}
* {
box-sizing: border-box;
outline: none;
}
img {
max-width: 100%;
}
body {
height: 100vh;
-webkit-font-smoothing: antialiased;
overflow: hidden;
color: #08090a;
display: grid;
place-items: center;
background-color: #d0d0d0;
font-family: var(--font);
background-image: url("//repo.bfw.wiki/bfwrepo/image/60505985a23e9.png");
background-repeat: no-repeat;
background-size: cover;
background-position: top center;
background-blend-mode: overlay;
padding: 0 80px;
}
@media (max-width: 980px) {
body {
padding: 0;
}
}
.container {
max-width: 1250px;
border-radius: 6px;
overflow-x: auto;
overflow-y: hidden;
max-height: 960px;
height: 90vh;
width: 100%;
display: flex;
scroll-behavior: smooth;
background-color: #f6f5f7;
box-shadow: 0 20px 70px rgba(0, 0, 0, 0.4);
}
@media (max-width: 980px) {
.container {
max-height: none;
border-radius: 0;
height: 100%;
}
}
.nav {
width: 100px;
height: 100%;
background-color: #08090a;
padding: 28px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
color: #fff;
position: relative;
z-index: 1;
flex-shrink: 0;
}
@media (max-width: 768px) {
.nav {
width: 60px;
}
}
.nav__text {
-ms-writing-mode: tb-rl;
writing-mode: vertical-rl;
transform: rotate(-180deg);
}
@media (max-width: 800px) {
.nav__text {
display: none;
}
}
.nav__shop {
width: 24px;
}
.nav__cart {
position: relative;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.nav__cart span {
background-color: var(--main-color);
border: 2px solid #08090a;
height: 20px;
display: flex;
font-weight: 500;
align-items: center;
justify-content: center;
border-radius: 50%;
font-size: 12px;
width: 20px;
color: #fff;
line-height: 1;
right: -6px;
top: -8px;
position: absolute;
}
.logo {
color: var(--main-color);
width: 32px;
}
.cover {
background-image: url("//repo.bfw.wiki/bfwrepo/image/60505985a23e9.png");
width: 500px;
display: flex;
justify-content: center;
font-size: 48px;
color: #fff;
background-repeat: no-repeat;
background-size: cover;
align-items: center;
background-position: center;
text-align: center;
font-weight: 500;
flex-shrink: 0;
}
@media (max-width: 768px) {
.cover {
width: 300px;
}
}
.product {
display: flex;
flex-direction: column;
align-items: center;
padding: 36px;
background-color: #fff;
width: 310px;
overflow-y: auto;
scroll-behavior: smooth;
transition: 0.6s;
flex-shrink: 0;
}
.product + .product {
margin-left: 6px;
}
.product__img {
width: 100%;
-o-object-fit: contain;
object-fit: contain;
margin: 40px 0;
max-width: 500px;
transition: 0.3s;
}
.product__title {
max-width: 12ch;
text-align: center;
font-size: 20px;
font-weight: 500;
margin: 20px 0;
transition: 0.6s;
}
.product__brand {
font-size: 14px;
letter-spacing: 1px;
transition: 0.6s;
}
.product__price {
margin-bottom: 30px;
transition: 0.6s;
}
.product__subtitle {
color: #414041;
line-height: 1.5em;
font-size: 14px;
margin-bottom: 20px;
}
.product__subtitle--expanded {
display: none;
}
.product__detail {
margin-top: auto;
font-weight: 500;
font-size: 14px;
letter-spacing: 1px;
}
.product__detail-img {
display: none;
}
.product__buttons {
align-items: center;
display: none;
min-width: 80%;
margin-bottom: 36px;
}
@media (max-width: 1010px) {
.product__buttons {
flex-direction: column;
justify-content: center;
}
}
.product__options {
display: flex;
align-items: center;
}
.product__option {
background-color: transparent;
border: 1px solid var(--border-color);
padding: 12px 20px;
font-size: 14px;
font-weight: 500;
letter-spacing: 1px;
font-family: var(--font);
margin-right: -1px;
}
@media (max-width: 650px) {
.product__option {
padding: 8px 16px;
}
}
.product__option:first-child {
border-radius: 4px 0 0 4px;
}
.product__option:last-child {
border-radius: 0 4px 4px 0;
}
.product__option--active {
background-color: var(--border-color);
color: #fff;
border-color: var(--border-color);
}
.product__option.product__add {
background-color: var(--main-color);
color: #fff;
margin-left: 16px;
flex-grow: 1;
border-radius: 4px;
border-color: var(--main-color);
}
@media (max-width: 1010px) {
.product__option.product__add {
margin-left: 0;
margin-top: 16px;
}
}
.product--active {
width: 70%;
padding-left: 70px;
padding-right: 70px;
overflow-y: auto;
padding-bottom: 0;
}
@media (max-width: 650px) {
.product--active {
width: 100%;
padding-left: 30px;
padding-right: 30px;
}
}
.product--active .product__title {
font-size: 44px;
max-width: none;
}
@media (max-width: 650px) {
.product--active .product__title {
font-size: 28px;
}
}
.product--active .product__detail {
display: none;
}
.product--active .product__price {
font-size: 24px;
}
.product--active .product__brand {
font-size: 16px;
}
.product--active .product__subtitle {
display: none;
}
.product--active .product__detail-img {
display: block;
margin-top: 20px;
margin: 20px -70px 0;
max-width: none;
width: calc(100% + 140px);
}
@media (max-width: 650px) {
.product--active .product__detail-img {
width: calc(100% + 60px);
}
}
.product--active .product__subtitle--expanded {
display: block;
-webkit-animation-name: transform;
animation-name: transform;
-webkit-animation-duration: 0.6s;
animation-duration: 0.6s;
-webkit.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0