div+css实现列表网格布局切换效果代码

代码语言:html

所属分类:布局界面

代码描述:div+css实现列表网格布局切换效果代码,列表可切换成网格和横向列表两种布局模式。

代码标签: div css 列表 网格 布局 切换

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

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

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

  
  
  
  
<style>
* {
	transform-style: preserve-3d;
	box-sizing: border-box;
}
		
body {
	margin: 0;
	padding: 0;
	width: 100vw;
	height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	perspective: 100vmin;
    background: #303030;
	overflow-x: hidden;
}

.button {
	width: 20vmin;
    height: 9vmin;
    background: #303030;
    display: flex;
    align-items: center;
    justify-content: center;
	border-radius: 3px;
	position: absolute;
	top: 11vmin;
}

.base {
    width: 17.5vmin;
    background: #00000066;
    height: 6.5vmin;
    border-radius: 4px;
    padding: 0.75vmin 0.5vmin 0.5vmin 0.125vmin;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #444;
    border-color: #000 #444 #444 #000;
}

#list-grid:checked ~ .button .base {
    padding: 0.75vmin 0.25vmin 0.5vmin 0.125vmin;
}

.selector {
    width: 16vmin;
    /* background: #33ff0066; */
    height: 5vmin;
	transition: 0.1s ease 0s;
}

.cuboid {
	--height: 5;
    --width: 8;
    --depth: 3;
    --hue: 200;
    --sat: 10%;
    height: calc(var(--height) * 1vmin);
    width: calc(var(--width) * 1vmin);
    position: absolute;
    animation: cube1 0.6s linear 0s infinite;
    transform: translate3d(0vmin, 0vmin, -1vmin);
}

.cuboid + .cuboid {
    margin-left: 8vmin;
    transform: rotateY(-15deg) translateZ(0.01vmin) translateX(0.25vmin);
}

.cuboid .side {
	position: absolute;
	top: 50%;
	left: 50%;
	height: 100%;
	width: 100%;
	border-radius: 2px;
}


.cuboid .side:nth-of-type(1) {
	transform: translate3d(-50%, -50%, calc(var(--depth) * 0.5vmin));
	background: hsl(var(--hue), var(--sat), 60%);
	border-radius: 2px 0 0 2px;
	border: 1px solid #fff;
    border-color: #fff6 #fff0 #fff0 #fff6;
}
.cuboid .side:nth-of-type(2) {
	transform: translate3d(-50%, -50%, calc(var(--depth) * -0.5vmin)) rotateY(180deg);
	background: hsl(var(--hue), var(--sat), 25%);
}
.cuboid .side:nth-of-type(3) {
	width: calc(var(--depth) * 1vmin);
	transform: translate(-50%, -50%) rotateY(90deg)	translate3d(0, 0, calc(var(--width) * 0.5vmin));
	background: hsl(var(--hue), var(--sat), 75%);
}
.cuboid .side:nth-of-type(4) {
	width: calc(var(--depth) * 1vmin);
	transform: translate(-50%, -50%) rotateY(-90deg) translate3d(0, 0, calc(var(--width) * 0.5vmin));
	background: hsl(var(--hue), var(--sat), 40%);
}
.cuboid .side:nth-of-type(5) {
	height: calc(var(--depth) * 1vmin);
	transform: translate(-50%, -50%) rotateX(90deg) translate3d(0, 0, calc(var(--height) * 0.5vmin));
	background: hsl(var(--hue), var(--sat), 75%);
}
.cuboid .side:nth-of-type(6) {
	height: calc(var(--depth) * 1vmin);
	transform: translate(-50%, -50%) rotateX(-90deg) translate3d(0, 0, calc(var(--height) * 0.5vmin));
	background: hsl(var(--hue), var(--sat), 20%);
}



.cuboid + .cuboid .side:nth-of-type(1) {
	border-radius: 0 2px 2px 0;
	/*box-shadow: 1vmin 0 1vmin 0 #0004 inset;*/
	border-color: #fff6 #fff6 #fff0 #fff0;
}

.cuboid .side:nth-of-type(1):before {
	content: "";
    position: absolute;
    width: 2.75vmin;
    height: 2.75vmin;
    background: conic-gradient(from 270deg at 50% 50%, #2b2b2b 0 25%, #fff0 0 100%);
    top: 1.15vmin;
    left: 2.5vmin;
    background-repeat: repeat;
    background-size: 1vmin 1vmin;
    background-position: 0vmin 0vmin;
}

.cuboid + .cuboid .side:nth-of-type(1):before {
    background: repeating-linear-gradient(180deg, #2b2b2b 0 0.45vmin, #fff0 0 1.05vmin);
}
		

label[for=list-grid] {
    width: 8vmin;
    height: 5vmin;
    /*background: repeating-linear-gradient(45deg, rgba(0, 128, 0, 0.281) 0 2px, transparent 0 4px);*/
    position: absolute;
    transform: translateZ(0.65vmin) rotateY(165deg);
    transform-origin: 100% 50%;
	cursor: pointer;
	box-shadow: -2vmin 0 1vmin 0 #0003 inset;
}

#list-grid:checked ~ .button label[for=list-grid] {
    transform: translateZ(0.65vmin) rotateY(0.1deg);
	box-shadow: -2vmin 0 1vmin 0 #fff4 inset;
}

#list-grid:checked ~ .button .selector {
    transform: rotateY(15deg);
    transform-origin: 50% 50%;
}

input {
	display: none;
}



.list {
    position: absolute;
    top: 30vmin;
    /*background: #ff000029;*/
    max-width: 80vmin;
    width: 100%;
}

.list ul {
    margin: 0;
    padding: 0;
    display: flex;
    list-style: none;
    width: 100%;
    flex-wrap: wrap;
}

.list ul li {
    width: calc(32% - 0.8vmin);
    display: flex;
    flex-direction: column;
    margin: 1%;
    transition: all 0.5s ease 0s;
    overflow: hidden;
    background: #1d1d1d;
    padding: 1.25vmin;
    border-radius: 3px;
    border: 1px solid #444;
    border-color: #000 #444 #444 #000;
}

#list-grid:checked ~ .list ul li {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
}

#list-grid:checked ~ .list ul li img {
    width: 40%;
}

#list-grid:checked ~ .list ul l.........完整代码请登录后点击上方下载按钮下载查看

网友评论0