javascript--Waterfall Flow Living room notes

Source: Internet
Author: User

<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>

Waterfall Flow

</title>
<style>
*{
font-size:12px;
}
. bar{
MARGIN:5PX Auto;
width:1016px;
height:20px;
border:1px solid #000;
}
#process {
width:10%;
height:100%;
Background-color: #ff0000;
}
. flow{
Margin:auto;
width:1016px;
position:relative;
border:1px solid #000;
height:2500px;
}
. Flow img{
width:250px;
}
. box{
Position:absolute;
Overflow:hidden;
width:250px;
box-shadow:0 1px 2px 0 rgba (180,180,180,.5);
Background: #fff;
border-radius:2px;
}
. Box img{
width:250px;
Height:auto;
}
. Box img:hover{
opacity:0.8;
Filter:alpha (opacity=80);
}
. message {
margin:0px 10px 11px;
padding-top:11px;
Overflow:hidden;
height:18px;
Color: #444;
line-height:18px;
}
. Message label{
Color: #999;
}
. Message a{
height:18px;
Color: #444;
Text-decoration:none;
Padding:0 4px;
Display:inline-block;
Zoom:1;
border-radius:2px;
Background-color: #f2f2f2;
margin-right:8px;
}
. Message a:hover{
Color: #fff;
Background-color: #e5461c;;
}
</style>
<script>
var tags=["Sweet vegan", "model", "Long Legged Beauty", "Street Beat", "fashion", "photo", "small fresh",
"Pure", "student Sister", "beautiful", "Sweet", "Lori", "Maid Outfit", "Rabbit Girl"];
var lefts=[0+2,251+4,251*2+6,251*3+8];
var tops =[0+2,0+2,0+2,0+2];
var boxs =[];
var imagecount=0;

Picture Load Complete Count
function Fncountimage () {
imagecount++;

var process = document.getElementById ("process");
var p = 100*imagecount/35;
Process.style.width= p.tofixed (0) + "%";

if (imagecount==35) {
Fninit ();
}
}

function Fnloadimage () {
for (Var i=1;i<=35;i++) {
var box = Fncreateimagebox (i);
Boxs.push (box);
}
}

Positioning of the initialized image
function Fninit () {
for (Var i=0;i<boxs.length;i++) {
var box = Boxs[i];
if (i<4) {
Positioning
box.style.left=lefts[i]+ "px";
box.style.top=tops[i]+ "px";

To modify the height of a column
tops[i]+=box.offsetheight+2;
}else{
Find the shortest height
var minheight = math.min (tops[0],tops[1],tops[2],tops[3]);
var minheight = Math.min.apply (null,tops);

Find the column with the shortest height
var index = 0;
for (Var j=0;j<tops.length;j++) {
if (Minheight==tops[j]) {
Index=j;
Break
}
}

Positioning
box.style.left=lefts[index]+ "px";
box.style.top=tops[index]+ "px";

To modify the height of a column
tops[index]+=box.offsetheight+2;
}
}
}

function Fncreateimagebox (Imgno) {
/*
<div class= "box" >

<p class= "Message" >
<label> label:</label>
<a href= "#" > Sweet Su Chun </a>
<a href= "#" > Models </a>
<a href= "#" > Long legged Beauty </a>
</p>
</div>
*/
var div = document.createelement ("div");
Div.classname= "box";

var img = document.createelement ("img");
var Imgno = imgno<10? ("0" +imgno): Imgno;
Img.setattribute ("src", "pic/p" +imgno+ ". jpg");
Img.onload = Fncountimage;
Div.appendchild (IMG);

var p = document.createelement ("P");
P.classname= "message";
Div.appendchild (P);

var label = document.createelement ("label");
Label.appendchild (document.createTextNode ("label:"));
P.appendchild (label);

var count = Fnrand (1,4);
for (Var i=0;i<count;i++) {
var a = document.createelement ("a");
A.setattribute ("href", "javascript:void (0)");
var text = Tags[fnrand (0,tags.length-1)];
A.appendchild (document.createTextNode (text));
P.appendchild (a);
}

document.getElementById ("Pics"). AppendChild (Div);
return div;
}
function Fnrand (Min,max) {
Return Math.floor (Math.random () * (max-min+1)) +min;
}

Window. Fnloadimage;
</script>

<body>
<div class= "Bar" ><div id= "process" ></div></div>
<div id= "Pics" class= "Flow" ></div>
</body>



javascript--Waterfall Flow Living room notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.