html5风景首页,HTML5+jQuery都市风景

JavaScript

语言:

JaveScriptBabelCoffeeScript

确定

function RandomColor(type) {

/// Creates a random color, returning it to the caller.

/// The type of random color to produce.

/// Possible values are "hex", "rgb", "rgba".

/// If not provided, a hexidecimal color is provided.

type = type ? type.toLowerCase() : "hex";

var result = "";

function Random(max) {

return Math.floor(Math.random() * (max + 1));

}

if (type == "hex") {

for (var i = 0; i < 3; i++) {

var color = ("0" + Random(256).toString(16));

result = result + color.substring(color.length - 2);

}

return "#" + result;

} else {

result = "";

for (var i = 0; i < 3; i++)

result += ", " + Random(256).toString(10);

if (type == "rgba")

result += ", " + (Math.floor(Math.random() * 100) / 100).toString(10);

return "rgb" + (type == "rgba" ? "a" : "") + "(" + result.substring(2) + ")";

}

}

$(function() {

var winWidth = $(document).width() * 5,

container = $("

");

for (var i = 0; i < 100; i++) {

var height = Math.floor((100 + Math.random() * 600 + Math.random() * Math.random() * 100) / 34) * 34,

width = Math.floor((100 + Math.random() * 100) / 26) * 26,

html = "";

for (var j = 0; j < height; j += 34)

for (var k = 0; k < width; k += 26)

html += "

var building = $("

", {

"class": "building",

html: html,

css: {

left: Math.random() * winWidth - 50,

height: height,

width: width,

background: "-webkit-linear-gradient(top left, " + RandomColor("rgb") + ", " +

RandomColor("rgb") + ")"

}

}).appendTo(container);

}

container.appendTo(document.body);

});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值