導航:首頁 > 萬維百科 > 網頁設計圖片下沉浮動

網頁設計圖片下沉浮動

發布時間:2020-12-09 03:40:03

1、怎樣製作網頁中的浮動層效果?

<!-- 完整的HTML代碼如下 -->
1.首先在<head>和</head>之間插入下列代碼
<br>
<style type="text/css">
#floater {
position: absolute;
left: 500;
top: 146;
width: 176;
visibility: visible;
z-index: 10;
}
-->
</style>
<br>

<br>
2.在body中的任意位置插入下列代碼

<div ID="floater" style="left: 590px; top: 158px">
<p align="center">
<img src="http://cfan.net.cn/tutu/200406301.jpg" width="127" height="150"><br>
<font color="#FF8040">歡迎光臨</font></p>
</div><script LANGUAGE="JavaScript">
self.onError=null;
currentX = currentY = 0;
whichIt = null;
lastScrollX = 0; lastScrollY = 0;
NS = (document.layers) ? 1 : 0;
IE = (document.all) ? 1: 0;
<!-- STALKER CODE -->
function heartBeat() {
if(IE) { diffY = document.body.scrollTop; diffX = document.body.scrollLeft; }
if(NS) { diffY = self.pageYOffset; diffX = self.pageXOffset; }
if(diffY != lastScrollY) {
percent = .1 * (diffY - lastScrollY);
if(percent > 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) document.all.floater.style.pixelTop += percent;
if(NS) document.floater.top += percent;
lastScrollY = lastScrollY + percent;
}
if(diffX != lastScrollX) {
percent = .1 * (diffX - lastScrollX);
if(percent > 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) document.all.floater.style.pixelLeft += percent;
if(NS) document.floater.left += percent;
lastScrollX = lastScrollX + percent;
}
}
<!-- /STALKER CODE -->
<!-- DRAG DROP CODE -->
function checkFocus(x,y) {
stalkerx = document.floater.pageX;
stalkery = document.floater.pageY;
stalkerwidth = document.floater.clip.width;
stalkerheight = document.floater.clip.height;
if( (x > stalkerx && x < (stalkerx+stalkerwidth)) && (y > stalkery && y < (stalkery+stalkerheight))) return true;
else return false;
}
function grabIt(e) {
if(IE) {
whichIt = event.srcElement;
while (whichIt.id.indexOf("floater") == -1) {
whichIt = whichIt.parentElement;
if (whichIt == null) { return true; }
}
whichIt.style.pixelLeft = whichIt.offsetLeft;
whichIt.style.pixelTop = whichIt.offsetTop;
currentX = (event.clientX + document.body.scrollLeft);
currentY = (event.clientY + document.body.scrollTop);
} else {
window.captureEvents(Event.MOUSEMOVE);
if(checkFocus (e.pageX,e.pageY)) {
whichIt = document.floater;
StalkerTouchedX = e.pageX-document.floater.pageX;
StalkerTouchedY = e.pageY-document.floater.pageY;
}
}
return true;
}
function moveIt(e) {
if (whichIt == null) { return false; }
if(IE) {
newX = (event.clientX + document.body.scrollLeft);
newY = (event.clientY + document.body.scrollTop);
distanceX = (newX - currentX); distanceY = (newY - currentY);
currentX = newX; currentY = newY;
whichIt.style.pixelLeft += distanceX;
whichIt.style.pixelTop += distanceY;
if(whichIt.style.pixelTop < document.body.scrollTop) whichIt.style.pixelTop = document.body.scrollTop;
if(whichIt.style.pixelLeft < document.body.scrollLeft) whichIt.style.pixelLeft = document.body.scrollLeft;
if(whichIt.style.pixelLeft > document.body.offsetWidth - document.body.scrollLeft - whichIt.style.pixelWidth - 20) whichIt.style.pixelLeft = document.body.offsetWidth - whichIt.style.pixelWidth - 20;
if(whichIt.style.pixelTop > document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5) whichIt.style.pixelTop = document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5;
event.returnValue = false;
} else {
whichIt.moveTo(e.pageX-StalkerTouchedX,e.pageY-StalkerTouchedY);
if(whichIt.left < 0+self.pageXOffset) whichIt.left = 0+self.pageXOffset;
if(whichIt.top < 0+self.pageYOffset) whichIt.top = 0+self.pageYOffset;
if( (whichIt.left + whichIt.clip.width) >= (window.innerWidth+self.pageXOffset-17)) whichIt.left = ((window.innerWidth+self.pageXOffset)-whichIt.clip.width)-17;
if( (whichIt.top + whichIt.clip.height) >= (window.innerHeight+self.pageYOffset-17)) whichIt.top = ((window.innerHeight+self.pageYOffset)-whichIt.clip.height)-17;
return false;
}
return false;
}
function dropIt() {
whichIt = null;
if(NS) window.releaseEvents (Event.MOUSEMOVE);
return true;
}
<!-- DRAG DROP CODE -->
if(NS) {
window.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN);
window.onmousedown = grabIt;
window.onmousemove = moveIt;
window.onmouseup = dropIt;
}
if(IE) {
document.onmousedown = grabIt;
document.onmousemove = moveIt;
document.onmouseup = dropIt;
}
if(NS || IE) action = window.setInterval("heartBeat()",1);
</script>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>

<br><br><br>
<p></p>

2、在網頁中如何製作一個隨著頁面滾動浮動的包含超鏈接的圖片?

直接放在浮動的div中

希望採納

3、IE67浮動問題(網頁設計)很簡單的效果。

把<li>定一個寬就行的了,會自動換行的 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns=" http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>無標題文檔</title> <style type="text/css"> *{margin:0;padding:0;list-style:none;outline:none; word-break:break-all;} div{ width:300px; padding:10px; overflow:hidden; border:1px solid #000000; margin:50px auto;} div ul{ width:300px; } div ul li{float:left; width:80px; line-height:24px; margin:0px 5px; } </style> </head> <body> <div> <ul> <li>收看1電視1</li> <li>收看1電視2</li> <li>收看1電視3</li> <li style="background:#00CCFF;">收看1電視4</li> <li>收看1電視5</li> <li>收1看電視6</li> <li>收1看電視7</li> </ul> </div> </body> </html>

4、怎麼在網頁中製作浮動的小圖標

1.新建一個HTLM的網頁.
2.轉到"布局"面板,選中"繪制層"按扭,在網頁上面畫一個圖層
3.然後,在圖層里放入你想要的內容,比如一張圖片等.
4.再次,在窗口欄中,將"時間軸"掉出來.也可Alt+F9.
5.這步最關鍵,將你繪制的圖層用滑鼠拖到時間軸上(注意是"拖動"哦),然後將時間上面的選項"自動播放"和"循環"勾起.
6.最後一步.在時間軸第一楨上,點擊滑鼠左鍵,選中"錄制層路徑",然後在網頁上拖動你畫的圖層.這時你會看見拖動圖層後面有些小點,那麼恭喜你,你這時是在繪制浮動廣告的路徑,繪完後,保存.預覽.完成了.(若想直線運動,可在針上點左鍵,選"添加關鍵針",再到網頁上移動圖層即可,如你懂FLASH,那就簡單了)

5、網頁設計浮動的問題

把你的背景圖片加引號background-image:url("images/header.jpg");

另外content層高度你可以不設,現在你裡面只放了一個left層,如果內容多的話它可以自動撐開的.

6、網頁設計,DIV+CSS問題,浮動問題

浮動最直接 最根本的原因就是兩個float的寬度和 大於總寬度。注意 IE下的偏移和margin在浮動下值的變化

7、dw cs5製作網頁 LOGO圖片向左浮動之後與下面的div標簽之間有個3像素的間隙,跪求解決辦法

#logo img {height:64px;width:200px;} img 加寬度和高度不起作用內聯元素要變成塊版元素先 display block

#logo { height: 64px; width:250px; float: left; display:inline} 這個權 displsy:inline多餘的

8、網頁設計,圖片的浮動,滑動滑鼠時圖片距離頂部邊框的長度總是一定的,代碼到底錯在哪裡了,幫忙看下

加上一張圖片 否則 把代碼拷進去以後什麼都看不見

9、網頁設計中浮動框怎麼製作?

浮動框還是浮動層?其實都一樣,知道做層就行了,加個浮動代碼就OK了

10、網頁設計清除浮動的問題

不是每一個div都需要清楚浮動,在ff中凡是樣式帶有float或者position屬性的div,都會被認為是浮動層,這樣的層在被父級div嵌套的時候是不會根據內容將父級撐開的,為了讓他既有float/position的效果還想根據內容撐開父級div,所以才會清除浮動。文字說的話也不是很明白,給你個例子。

下面的例子你可以很明顯的看出在FF和在IE中的不同

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文檔</title>
<style type="text/css">
.clear {clear: both;}
</style>
</head>
<body>
<div style="background-color:#666; width:500px;">
<div style="float: left;width: 130px;">內容 內容</div>
</div>
</body>
</html>

如果加上clear清楚浮動的話,效果就相同了。
<div style="background-color:#666; width:500px;">
<div style="float: left;width: 130px;">內容 內容</div>
<div class="clear"></div>
</div>

與網頁設計圖片下沉浮動相關的知識