在我的太陽能系統網站上,我希望每次訪問該網站時都會在背景上隨機放置大量白色小圓圈(可能爲1或2像素大)。圓圈不一定是scr =「」圖像,它可以是普通的白色圓圈。隨機定位圖像
html {
background-color: #000;
}
.sun {
position: absolute;
height: 100px;
width: 100px;
top: 50%;
left: 50%;
margin-left: -50px;
margin-top: -50px;
border-radius: 50%;
box-shadow: rgb(204, 153, 0) 0px 0px 50px 0px;
}
.earth {
height: 25px;
width: 25px;
border-radius: 50%;
box-shadow: green 0 0 25px;
}
.earth-orbit {
position: absolute;
height: 200px;
width: 200px;
top: 50%;
left: 50%;
margin-left: -100px;
margin-top: -100px;
/*border-radius: 50%;*/
/*border: 1px dotted gray;*/
-webkit-animation: spin-right 10s linear infinite;
}
.moon {
height: 10px;
width: 10px;
}
.moon-orbit {
top: 50%;
left: 50%;
height: 50px;
width: 50px;
margin-left: -12.5px;
margin-bottom: -37px;
border: 1px solid rgba(255, 0, 0, 0.1);
border-radius: 50%;
-webkit-animation: spin-right 1s linear infinite;
}
@-webkit-keyframes spin-right {
100% {
-webkit-transform: rotate(360deg);
}
}
<!DOCTYPE html>
<html>
<head>
<title>Vanishing Act</title>
<link rel='stylesheet' type='text/css' href='stylesheet.css' />
<script type='text/javascript' src='script.js'></script>
</head>
<body>
<img class="sun" src="sun_transparent.png">
</div>
<div class="earth-orbit">
<div class='moon-orbit'>
<img class="moon" src="https://dl.dropboxusercontent.com/u/24899062/cc/moon.png" />
</div>
<img class="earth" src="https://dl.dropboxusercontent.com/u/24899062/cc/earth.png" />
</div>
</body>
</html>
而且,什麼是你的問題?你卡在哪裏? – 2014-12-07 00:29:28
我的問題是我該怎麼做,我不想單獨定位每顆星星,我需要javascript來爲我做並隨機化它。 – user4191887 2014-12-07 00:32:06
好的,但你卡在哪兒..? – 2014-12-07 00:34:17