gpt4 book ai didi

javascript 条形音箱上去

转载 作者:行者123 更新时间:2023-11-28 17:18:24 25 4
gpt4 key购买 nike

我找到了 this pen在代码笔上。我想使用它,但是条形图向下而不是向上 我怎样才能让它向上?

var elem = $('div');
var count = elem.length;

var loop = function() {

setTimeout(function() {
elem.each(function() {
var $this = $(this);
var height = (Math.random() * 20) + 1;
$this.css({
'background': 'rgba(255, 255, 255,1)',
'top': height,
'height': height
});
});
loop();
}, 320);

}

loop();
section {
width: 100%;
display: inline-block;
margin: auto;
background: #222;
}

div {
background: #fff;
float: left;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
vertical-align: middle;
height: 1px;
transition: all linear 250ms;
width: 2px;
margin-left: 1px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<section>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section>

最佳答案

var elem = $('.sound-bars div');
var count = elem.length;

var loop = function(){

setTimeout(function(){
elem.each(function(){
var $this = $(this);
var height = (Math.random() * 20) + 1;
$this.css({
'height': height
});
});
loop();
}, 320);

}

loop();
.sound-bars {
width: 100%;
display: flex;
background: #222;
position: absolute;
bottom: 0;
align-items: baseline;
}
.container {
height: 80px;
position: relative
}
.sound-bars div {
background: #fff;
height: 1px;
transition: all linear 250ms;
width: 2px;
margin-left:1px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="sound-bars">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>

关于javascript 条形音箱上去,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43089535/

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