2017-03-29 3 views
-1

코덱에서 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>

+0

이들은 ''배경 '필요하지 않다'RGBA (255, 255, 255,1) ' '상단 '높이 ' – mplungjan

답변

1

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 { 
 
\t 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>

+0

감사합니다 :) 완벽하게 작동합니다. – Enkhtuvshin

관련 문제