-
節省流量用字符集制作圖標查看全部
-
html:查看全部
-
css 2: 自適應width:100%; 去掉焦點:outline:none;查看全部
-
css1: body{font-size:12px/1.5 tahoma,arial,sans-serif;} //默認字集,所有瀏覽器能識別到 a{text-decoration:none; } .search-tips,.search-button{float:right; } .search-tips{padding:3px 0 0 15px;} .search-tips a{color:#6c6c6c; } .btn-search{background-image:url(../img/1H.ico); background-repeat:no-repeat; /* background-position:0 -200px;*/ background-size:60px 100%; width:60px; height:35px; border:0; cursor:pointer; } .search-common{ height:39px; background-color:#f50; overflow:hidden; padding:3px 0 3px 77px; } .search-common input{ height:39px; line-height:39px; width:100%; border:0 none; outline:none; background-color:#fff; }查看全部
-
font:12px/1.5; //字體12像素 行高 1.5em 字體 1.5(注意沒有單位,只是數字)表示 line-height 為當前字體大小的 1.5倍 這是css中font的簡寫寫法。 字體:字體大小/字體行高 字體格式 tahoma 大河馬字體,Tahoma為Windows操作系統的英文默認字型。Tahoma是種非常圓滑的字體。這個字體比較均衡,中英文混排顯示時,不會出現中英文不對齊的狀態。 arial 是一套隨同多套微軟應用軟件所分發的無襯線體TrueType字型 sans-serif 表示是無襯線字體,是一種通用字體族。查看全部
-
最后緩存:Fiddler工具var getId=function(id){ return document.getElementById(id); } var addEvent = function(id,event,fn){ //容錯防止id不對報錯 var ele = getId(id)||document; if(ele.addEventListener){ ele.addEventListener(event,fn,false); }else if(ele.attachEvent){ ele.attachEvent('on'+event,fn); } } var Left = function(element){ var oleft = element.offsetLeft; var current = element.offsetParent; while(current!==null){ oleft += current.offsetLeft; current = current.offsetParent; } return oleft; } var Top = function(element){ var otop = element.offsetTop; var parent = element.offsetParent; while(parent!==null){ otop += parent.offsetTop; parent = parent.offsetParent; } return otop; }查看全部
-
事件代理:點擊跳轉到指定頁面 var ajaxGet = function(url,callback){ //發送請求 var _xhr= null; if(window.XMLHttpRequest){ _xhr = new window.XMLHttpRequest(); }else if(window.ActiveXObject){ _xhr = new window.ActiveXObject("Msxml2.XMLHTTP"); } //響應服務器請求 _xhr.onreadystatechange = function(){ if(_xhr.status==200 && _xhr.readyState==400){ callback(JSON.parse(_xhr.responseText)); } } //發送請求false異步 _xhr.open("get",url,false); _xhr.send(null); } //事件代理跳轉 var delegate = function(target,event,fn){ addEvent(document,event,function(e){ if(e.target.nodeName==target.toUpperCase()){ fn.call(e.target); } }) }查看全部
-
獲取value內容li拼接一起發送給服務器:查看全部
-
發送請求-響應服務器請求//ajax發送請求獲得后臺數據 addEvent("search-input","keyup",function(){ //獲取要發送的值 var searchText = getId("search-input").value; ajaxGet("http://api.bing.com/qsonhs.aspx?q="+searchText,function(d){ var d = d.AS.Results[0].Suggests; var html = ""; for(var i=0; i<d.length; i++){ html += "<li>" + d[i].Txt + "</li>"; } getId("search-result").innerHTML = html; //38 form表單搜索框的高度 getId("search-suggest").style.top = Top(getId("search-form"))+38+"px"; getId("search-suggest").style.left = Left(getId("search-form"))+"px"; getId("search-suggest").style.position="absolute"; getId("search-suggest").style.display="block"; }); }); delegate('li','click',function(){ var keyword = this.innerHTML; location.+keyword; });查看全部
-
最后部分靜態:38是文本搜索框查看全部
-
top封裝:找到父元素的父元素的left相加一直找到跟目錄沒有父元素的那個。取元素到瀏覽器最頂部的距離查看全部
-
構建函數,封裝函數: var getId=function(id){ return document.getElementById(id); } ps://容錯防止id不對報錯var ele = getId(id)||document;查看全部
-
html:查看全部
-
ajax跨域報錯:解決:可以在本地修改host文件 映射 api.bing.com 127.0.0.1 jsonp: http://blog.csdn.net/zhouyusong_bupt查看全部
-
ajax跨域報錯:解決:可以在本地修改host文件 映射 api.bing.com 127.0.0.1查看全部
舉報
0/150
提交
取消