var speeds = [];
var count = 1;
var colors = ['#bf1e2e', '#ee4037', '#dc5323', '#e1861b', '#e1921e', '#f7ac40', '#f7e930', '#d1da22', '#8bc43f', '#38b349', '#008d42', '#006738', '#29b473', '#00a69c', '#26a9e1', '#1a75bb', '#2a388f', '#262161', '#652d90', '#8e2792', '#9e1f64', '#d91c5c', '#ed297b', '#d91c5c', '#db1e5e', '#bf1e2e', '#f6931e', '#f05a28', '#f6931e', '#fbaf41']
var width = parseInt($('html').css('width'), 10);
var random = function(mult, add) {
return Math.floor((Math.random()*mult) + add);
};
var drop = function(n, height, color) {
$('.myeffect').append('<div class="drop" style="left:'+
n*15+'px;height:'+
height+'vh;background-color:'+
color+';"></div>');
};
var createDrops = function(space) {
for (var i=speeds.length; i < space/10; i++) {
speeds.push(random(3000, 2000));
drop(i, random(70, 30), colors[count]);
if (count < colors.length-1) { count++; }
else { count = 0; } \t \t
}
};
var animateDrops = function(startingN) {
for (var i=startingN; i<speeds.length; i++) {
$('.drop:nth-child('+i+')').slideDown(speeds[i]);
}
};
createDrops(width);
animateDrops(0);
.drop {
width: 16px;
height: 200px;
display: none;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
position: absolute;
top: 0;
-webkit-box-shadow: inset -4px -8px 16px -6px rgba(0,0,0,0.47);
-moz-box-shadow: inset -4px -8px 16px -6px rgba(0,0,0,0.47);
box-shadow: inset -4px -8px 16px -6px rgba(0,0,0,0.47);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="myeffect" ></div>
Versuchen Sie, '.myEffect' eine Breite und Höhe. Sie werden sehen, dass die Tropfen immer noch das gesamte Fenster ausfüllen. Ich bin mir ziemlich sicher, OP möchte, dass die Drips nur innerhalb des Divs gerendert werden. – Turnip
Genau @Turnip, ist die Idee, den Effekt in einem div unterhalb der Website Header und Navigationsmenü mit einer Höhe von 60% der Bildschirmhöhe geladen haben. Die Kopie der Webseite sollte unterhalb des Effekts fortgesetzt werden. Das oben genannte funktioniert nicht wirklich. Es zeigt einen x-Überlauf aus irgendeinem Grund und es ist immer noch außerhalb eines DIV. Ich arbeite immer noch daran und werde es hoffentlich mit deiner Hilfe herausfinden. –