背景图自适应
js:
$(".bg-img").css("width", document.body.clientWidth);
css:
.bg_img
{
background-image: url(/img/bg.png);
background-attachment:fixed;
background-repeat:no-repeat;
background-size:cover;
-moz-background-size:cover;
-webkit-background-size:cover;
}
//适应移动设备
.bg-img
{
position: absolute;
left: 0px;
top: 0px;
z-index:-2;
}
移动设备屏幕大小
alert(document.body.clientWidth+" "+document.body.clientHeight );
移动设备,禁止滚动
document.body.addEventListener(
'touchmove',
function (event)
{
event.preventDefault();
},
false
);
透明背景
.bg-white
{
background-color:rgba(255, 255, 255, 0.50);
padding: 25px;
margin-top:20px;
}
JS引用JS
<script type=text/javascript>
if (typeof SWFObject == "undefined") {
document.write('<scr' + 'ipt type="text/javascript" src="/scripts/XXX.js"></scr' + 'ipt>');}
</script>
setTimeout
setTimeout 不能在$(doc..).ready(function(){});中使用 。
想调用传参数方法,用function(){ method(param);}
jq show()/hide()
该两方法会将display:none
如果是row结构,show回来时记得将display:inline,否则会变形
jq each
如果将统一class或标签的属性修改记得用each,否则会有些class或标签的属性修改不成功