MontefuckeR
Registered
Дайте някой JS да върши действие като скролираш нагоре-надолу, снимка да ходи по скрола
Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
/***********************************************
* Floating Top Bar script- © Dynamic Drive (www.dynamicdrive.com)
* Sliding routine by Roy Whittle (http://www.javascript-fx.com/)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var startX = 10 //set x offset of bar in pixels
var startY = 20 //set y offset of bar in pixels
var verticalpos="frombottom" //enter "fromtop" or "frombottom"
function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function staticbar(){
barheight=document.getElementById("webdesignby").offsetHeight
var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
var d = document;
function ml(id){
var el=d.getElementById(id);
if(d.layers)el.style=el;
el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};
el.x = startX;
if (verticalpos=="fromtop")
el.y = startY;
else{
el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight;
el.y -= startY;
}
return el;
}
window.stayTopLeft=function(){
if (verticalpos=="fromtop"){
var pY = ns ? pageYOffset : iecompattest().scrollTop;
ftlObj.y += (pY + startY - ftlObj.y)/7;
}
else{
var pY = ns ? pageYOffset + innerHeight - barheight: iecompattest().scrollTop + iecompattest().clientHeight - barheight;
ftlObj.y += (pY - startY - ftlObj.y)/7;
}
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("stayTopLeft()", 10);
}
ftlObj = ml("webdesignby");
stayTopLeft();
}
if (window.addEventListener)
window.addEventListener("load", staticbar, false)
else if (window.attachEvent)
window.attachEvent("onload", staticbar)
else if (document.getElementById)
window.onload=staticbar
#webdesignby a:link { text-decoration: none; color: #FF0000; }
#webdesignby a:visited { text-decoration: none; color: #FF0000; }
#webdesignby a:hover { text-decoration: underline; color: #FF0000; }
#webdesignby a:active { text-decoration: underline; color: #FF0000; }
#webdesignby {
position: absolute;
bottom: 10px;
left: 0px;
height: 0px;
width: 70px;
padding: 20px;
font-size: 12px;
font-weight: none;
color: #FF0000;
text-align: center;
z-index: 1000;
}
<script type="text/javascript" src="scroll.js"></script>
<link href="scroll.css" type="text/css" rel="stylesheet" /></head>
<div id="webdesignby">Тук е снимката.</div>
id="img"
<img src="URL адреса" id="img" alt="Някакъв текст" />
#img{
position: fixed;
top: 10px;
left: 10px;
height: 100px;
width: 150px;
}