.html
<p class="img01"><script type="text/javascript">img.put();</script></p>.css
div {
position:relative;
line-height:0;
}
p {
position: absolute;
}
.img01 {
position: absolute;
top: 50px;
left: 100px;
}
top:50px;が効かずウインドウの一番左上に表示されてしまうのですが何が原因でしょうか?
img.put() は何をしてるんですか?
複数の画像からアクセスする度にランダムで表示しています。
<script type="text/javascript">
var img01 = {
url : [['01.png'],['02.png'],['03.png'],['04.png'],['05.png']],
shuffle : function() {
for (i = this.url.length; i > 0; --i) {tmp = this.url[p = Math.floor(Math.random()*i)] ;
this.url[p] = this.url[i-1] ;this.url[i-1] = tmp ;}},p : 0,put : function() {document.write('<img src="'+this.url[this.p++][0]+'" />') ;
if (this.p >= this.url.length) this.p = 0 ;
}
} ;
img01.shuffle() ;
</script>
質問に追記してください。あと、マークダウンを使ってくださいね。見にくいです。
回答2件
あなたの回答
tips
プレビュー