1.position與滾動條的問題html
一個div做爲父元素,其子元素的position=absolute的時候,若是位置超過了div的範圍就顯示到外面去了,而若是position=relative時,範圍超出時,div就會出現滾動條,子元素仍在div內部。web
解決辦法:overflow:auto;瀏覽器
2.圖片上傳顯示爲縮略圖解決辦法:app
<img src="'+data[i].images[j]+'?imageView2/1/w/300/h/300" alt="加載中..." onerror="$(this).hide();"/>
3.設置圖片寬度自適應,不用擔憂圖片變形的問題框架
<div style="width:600px; position:relative; padding-bottom:600px; height:0;">
ide
<img src="xxx.png" style="width:100%; height:100%; position:absolute;" />
</div>
this
4.點擊空白區域收回彈框url
//顯示隱藏搜索框
$('.search-button').click(function(){
some code;
});
$("body").click(function (e) {
console.log($(e.target));
if ($(e.target).parent().attr("class")=='search-button'||$(e.target).attr("class")=='輸入框類名'){}
else{
aother code;
}
});
5.設置input裏面的placeholder的屬性
input:-ms-input-placeholder {
/* Internet Explorer 10+ */
color: rgb(255, 255, 255);
font: 18px/50px "Microsoft Yahei Regular";
text-indent: 10px;
}
input::-webkit-input-placeholder {
color: rgb(255, 255, 255);
font: 18px/50px "Microsoft Yahei Regular";
text-indent: 10px;
}
input:-moz-placeholder {
/* Mozilla Firefox 4 to 18 */
color: rgb(255, 255, 255);
font: 18px/50px "Microsoft Yahei Regular";
text-indent: 10px;
}
input::-moz-placeholder {
/* Mozilla Firefox 19+ */
color: rgb(255, 255, 255);
font: 18px/50px "Microsoft Yahei Regular";
text-indent: 10px;
}
6.自定義鼠標指針樣式
cursor: url("/public/img/fangda.png"), auto;
url是自定義圖片,後面的參數能夠是auto,default,pointer等,表示在未找到自定義圖片樣式時指針的顯示樣式。
7.引用框架,設置框架的高度減去固定高度後全屏填滿
body:<iframe width="100%" height="100%" src="index.html" style="margin-top: 60px;" id="mapFrame"/>
CSS:設置html,body{height:100%;}
JQ:$("#mapFrame").height(document.body.clientHeight-60);
8.手機屏幕固定填充背景圖片,不疊加
body{
background: url('/img/beijing.jpg');
background-size: cover;
background-attachment: fixed;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/beijing.jpg',sizingMethod='scale');(IE瀏覽器)
}
9.jq中append()、prepend()、after()、before()的區別詳解
一、append() - 在被選元素的結尾插入內容(內容的結尾,好比說有個a標籤,則是在</a>這個標籤以前添加東西) 二、prepend() - 在被選元素的開頭插入內容(內容的開始,好比說有個a標籤,則是在<a>這個標籤以後添加東西) 三、after() - 在被選元素以後插入內容(元素的結尾,好比說有個a標籤,則是在</a>這個標籤以後添加東西) 四、before() - 在被選元素以前插入內容(內容的開始,好比說有個a標籤,則是在<a>這個標籤以前添加東西)