我得到了代码工作,基本上。我无法将图片设置为网站布局的右上角。这是违反底部权利,这不是我想要的。Javascript随机背景右上角固定
获取它的任何帮助,使图像显示在右上角,因为我不知所措。
我敢打赌这件事很简单。 >的.o
<script type='text/javascript'>
var bgColorArray = ['http://s33.postimg.org/5xlufyx6n/image.png','http://s33.postimg.org/y1sy7zkvz/BG2.png','http://s33.postimg.org/icmelisu7/BG3.png','http://s33.postimg.org/twvtrar9b/BG4.png','http://s33.postimg.org/xvy4urypr/BG5.png','http://s33.postimg.org/kpmh0h75r/BG6.png','http://s33.postimg.org/7d6aukl8f/BG7.png','http://s33.postimg.org/3xsf9m933/BG8.png','http://s33.postimg.org/4dhh7uz5r/BG9.png','http://s33.postimg.org/6kzi108lb/BG10.png','http://s33.postimg.org/3jmyfngjj/BG11.png','http://s33.postimg.org/55klqfkan/BG12.png'],
selectBG = bgColorArray[Math.floor(Math.random() * bgColorArray.length)];
document.body.style.backgroundImage = 'url(' + selectBG + ')';
</script>
按照此要求是真实所进行的CSS的一部分:
对没错,这里是一个的所进行的CSS:
html,body {
background: url(http://s33.postimg.org/7nk1hqiwv/Woosh2.png) right bottom fixed no-repeat, url(http://s33.postimg.org/nk9mmywjj/ONEMORETIME.png) left top fixed no-repeat, url(http://s33.postimg.org/xgapmm2bj/Left_Side_Repeat.png) left bottom fixed repeat-y, url(http://s33.postimg.org/k00q0gawv/6_Done.png) fixed repeat;
color:#FFF;
text-shadow:#000 1px 1px 0;
font-family: "Comic Sans MS", "Trebuchet MS", "Bitstream Vera Sans", "Verdana", sans-serif;
font-size: 12px;
margin: 0;
padding:0;
height: 100%;
}
至于它的HTML在论坛主持人Zetaboards上。所以HTML大部分是自动的。
你可以张贴一些HTML和CSS文件?你的问题不在于提供的js代码(我想你的bg图像在屏幕上呈现)。 – ali404
你......实际上是通过问这个问题来解决我的问题。它将它放置在我正在进行的背景图像的最顶层位置。你是一个天才。 ;) –
看看这个基于你的代码https://plnkr.co/edit/zEQbUhvDE4Ug2GYL96Tc?p=preview创建的plunker,希望它有帮助,否则做修改,因为你的代码,让我们知道你在哪里面临的问题。 – Deep