gpt4 book ai didi

javascript - div 无法正常工作

转载 作者:行者123 更新时间:2023-11-28 02:51:31 26 4
gpt4 key购买 nike

我制作了一个我想要限制的粒子效果,以便它覆盖整个屏幕(而不是整个网页),从而创建视差类型的效果。问题是我可以用像素限制高度但是当我尝试使用 height: 100vh; div class="main tag"下面的任何内容都不会出现。有什么帮助吗?

这是我的 html:

<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>A Pen by Rithik Kapoor </title>



<link rel="stylesheet" href="css/style.css">


</head>

<body>
<head>
<link href='https://fonts.googleapis.com/css?family=Righteous' rel='stylesheet' type='text/css'>
</head>
<body>
<section>
<div class="main" id="particles-js">
<center>
<div class="whole">
<div class="wrap">
v
</div>
<p>
COMP D' AFFAIRES<p></center>

</div>
</div>
</section>
<div id="box">
lol
</div>

<script src='https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js'></script>

<script src="js/index.js"></script>


</body>
</html>

我的 CSS:

html{
width:100%;
height:100%;
overflow:hidden;
}
body{
margin:0;
padding:0;
width:100%;
font-rendering:optimizeLegibility;
-webkit-font-smoothing: antialiased;
height:100%;
font-family: 'Righteous', cursive;
color: white;
font-size: 100px;
}
.main{
width:100%;
height:100vh;
background: #000000;
background-attachment: fixed;
background-size:cover;
display:table;

}
.wrap{
font-size: .7em;
overflow: hidden;
margin:0;
width: 100px;
height:100px;
border-radius: 100%;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
-webkit-transition:all 0.3s ease;
transition: all 0.3s ease;
position: absolute;
left:400px;
bottom: -100px;
padding: 0px;
margin: 0px;

}
.wrap:hover{
box-shadow: 0px 0px 0px 8px #4F5E7F;
border: solid 4px #965F8A;

}
.wrap img{
width:100%;
}
.whole{
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}

#box {
background-color:black;
height:100vh;
width:100%;
background-attachment: fixed;
background-size:cover;
display:table;
z-index:1000000;

}

我的javascript:

particlesJS("particles-js", {
"particles": {
"number": {
"value": 80,
"density": {
"enable": true,
"value_area": 800
}
},
"color": {
"value": "#11ff00"
},
"shape": {
"type": "circle",
"stroke": {
"width": 0,
"color": "#000000"
},
"polygon": {
"nb_sides": 5
},
"image": {
"src": "img/github.svg",
"width": 100,
"height": 100
}
},
"opacity": {
"value": 0.9,
"random": false,
"anim": {
"enable": false,
"speed": 1,
"opacity_min": 0.1,
"sync": false
}
},
"size": {
"value": 4,
"random": true,
"anim": {
"enable": false,
"speed": 40,
"size_min": 0.1,
"sync": false
}
},
"line_linked": {
"enable": true,
"distance": 150,
"color": "#ff0000",
"opacity": 0.4,
"width": 1
},
"move": {
"enable": true,
"speed": 6,
"direction": "none",
"random": false,
"straight": false,
"out_mode": "out",
"bounce": false,
"attract": {
"enable": false,
"rotateX": 600,
"rotateY": 1200
}
}
},
"interactivity": {
"detect_on": "canvas",
"events": {
"onhover": {
"enable": true,
"mode": "grab"
},
"onclick": {
"enable": true,
"mode": "push"
},
"resize": true
},
"modes": {
"grab": {
"distance": 140,
"line_linked": {
"opacity": 1
}
},
"bubble": {
"distance": 400,
"size": 40,
"duration": 2,
"opacity": 8,
"speed": 3
},
"repulse": {
"distance": 200,
"duration": 0.4
},
"push": {
"particles_nb": 4
},
"remove": {
"particles_nb": 2
}
}
},
"retina_detect": true
});

/* ---- stats.js config ---- */

var count_particles, stats, update;
stats = new Stats;
stats.setMode(0);
stats.domElement.style.position = 'absolute';
stats.domElement.style.left = '0px';
stats.domElement.style.top = '0px';
document.body.appendChild(stats.domElement);
count_particles = document.querySelector('.js-count-particles');
update = function() {
stats.begin();
stats.end();
if (window.pJSDom[0].pJS.particles && window.pJSDom[0].pJS.particles.array) {
count_particles.innerText = window.pJSDom[0].pJS.particles.array.length;
}
requestAnimationFrame(update);
};
requestAnimationFrame(update);

最佳答案

你正在使用 overflow:hidden here look

html{
width:100%;
height:100%;
overflow:hidden;
}

删除这个溢出:隐藏看看外面 Here is the working fiddle

关于javascript - div 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46652275/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com