背景圖自適應
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或標籤的屬性修改不成功