1. CSS3 dialog Box
talk{width:100px; height:30px; background: #ffffff; border-radius:5px; position:absolute; left:100px; top:100px;}. Talk:after{content: ""; border-width:10px 20px; Border-style:dashed solid solid dashed; Position:absolute; Left: -20px; top:17px; Border-color:transparent #ffffff #ffffff Transparent; Transform:rotate ( -40DEG)}
2. compatible with IE6 Sidebar code (no more scripting)
Sel-box{float:left; z-index:9999; position:fixed; background: #000; width:170px; height:175px; top:172px;left:50%; margin-left:500px; _position:absolute;_top:expression (documentelement.scrolltop+172); Visibility:hidden;}
3.
slide jump Anchor Point ( Remember the premise connection JQ library)
$ (Window). bind ("Scroll resize", function () {var winwi DTH = $ (window). width (); var winheight = $ (window). Height (); if (Winwidth > 1250 && $ (window). scrolltop () > Winheight) {$ ('. Sel-box '). CSS (' visibility ', ' visible ' ); } else {$ ('. Sel-box '). CSS (' visibility ', ' hidden '); } }); Anchor point Jump Slide effect $ (' a[href*=#],area[href*=#] '). Click (function () {if (Location.pathname.replace (/^\//, ') = = = This.pat Hname.replace (/^\//, ') && location.hostname = = this.hostname) {var $target = $ (This.hash); $target = $target. Length && $target | | $ (' [name= ' + this.hash.slice (1) + '] '); if ($target. length) {var targetoffset = $target. Offset (). Top; $ (' html,body '). Animate ({Scrolltop:targetoffset}, 1000); return false; } } });
4. Using the REM layout
Get screen width Change the value of REM settings var cwidth = Document.documentElement.clientWidth | | document.body.clientWidth; Console.log (cwidth); Document.documentElement.style.fontSize = (cwidth/640*20) + "px";
Where 640 is the width of the design manuscript
5. Mobile-Move Events
var StartX = 0, starty = 0, moveX = 0, movey = 0; Window.addeventlistener ("Touchstart", function (EV) { StartX = Ev.touches[0].pagex; Starty = Ev.touches[0].pagey; }, False); Window.addeventlistener ("Touchmove", function (EV) { ev.preventdefault ();//Cancel Browser default action MoveX = ev.touches[0 ].pagex; Movey = Ev.touches[0].pagey; }, False); Window.addeventlistener ("Touchend", function (EV) { if (movex==0) { console.log (' same position '); } else{ if (Startx-movex < -50) { Console.log ("left Slide"); } if (Startx-movex >) { console.log ("right-sliding");}} }, False);
6. Get the parameters of the address bar
function getquerystring (name) { var reg = new RegExp ("(^|&)" + name + "= ([^&]*] (&|$)"); var r = window.location.search.substr (1). Match (reg); if (r!=null) return unescape (r[2]); return null; } var nums = getquerystring (' RDM '); such as: www.baidu.com?rdm=0; At this point 0 can be obtained by nums
Tips for refactoring