当前位置:首页 > 代码 > 正文

网页悬浮搜索框代码(网页悬浮窗代码)

admin 发布:2022-12-19 16:02 123


本篇文章给大家谈谈网页悬浮搜索框代码,以及网页悬浮窗代码对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

网页中如何加入悬浮窗口?能一直悬浮在浏览器某个地方的。

1、首先创建一个名为“topwindows.html”的网页文件,其中的内容将被展示主页浮动窗口中。

2、网页浮动窗口对应的部分代码如下所示:

html

style

.img_wd{

font-size:30;padding-top:20px;

text-align:left;padding-left:70px;line-height:40px;

background:url(110.jpg) top center no-repeat;

width:252px;height:127px;line-heiht:10px;

text-align:center;

font-family:"微软雅黑,仿宋,楷体,黑体"

color: #fafafa;

text-shadow : rgba(255,255,255,0.5) 0 5px 6px, rgba(255,255,255,0.2) 1px 3px 3px;

}

/style

body

div class="img_wd" style=""

青春就是这么任性!Br

Younger GOOD

/div

/body

/html

3、接着将如图所示的代码添加到主页Body和/Body之间:

其中标签"fdck”中的属性SRC指向浮动窗口的网页地址。

div id="img" style="position: absolute;visibility :hidden;padding:0px;" onmouseover="clearInterval(interval)" onmouseout="interval = setInterval('changePos()', delay)" align="middle"

span style="CURSOR:hand;color:red;font-weight:bold;font-align:center;font-size:12px;padding-left:0px;" onclick="clearInterval(interval);fdck.style.visibility = 'hidden';img.style.visibility = 'hidden';"隐藏/span

div id="fdck" style="width:100%; height:100%; font-align:center; visibility:visible;border:0px; background-color: no"

iframe width=320 height=150 src="topWindows.html" frameborder=no scrolling="no"

/iframe

/div

/div

4、接下来需要添加浮动窗口随时运行的行为,对应代码如下:

script language=javascript

var xPos = 20;

var yPos = document.body.clientHeight;

var step = 1;

var delay = 30;

var height = 0;

var Hoffset = 0;

var Woffset = 0;

var yon = 0;

var xon = 0;

var pause = true;

var interval;

img.style.top = yPos;

function changePos() {

width = document.body.clientWidth;

height = document.body.clientHeight;

Hoffset = img.offsetHeight;

Woffset = img.offsetWidth;

img.style.left = xPos + document.body.scrollLeft;

img.style.top = yPos + document.body.scrollTop;

if (yon) {yPos = yPos + step;}

else {yPos = yPos - step;}

if (yPos 0) {yon = 1;yPos = 0;}

if (yPos = (height - Hoffset)) {yon = 0;

yPos = (height - Hoffset);}

if (xon) {xPos = xPos + step;}

else {xPos = xPos - step;}

if (xPos 0) {xon = 1;xPos = 0;}

if (xPos = (width - Woffset)) {xon = 0;xPos = (width - Woffset);}

}

function start() {

img.style.visibility = "visible";

interval = setInterval('changePos()', delay);}

start();

/script

5、在此需要说明一点,需要将以上所有代码(包括JS脚本)全部放置在body和/body之间。

6、最后查看一下浮动窗口的效果,会发现浮动窗口在网页中不断的移动,当鼠标悬停其上时会停止移动,点击“隐藏”按钮将自动隐藏悬浮窗口。

如果想在网页上增加一个浮动的搜索栏,怎么做?

自己刚找的,按照自己的弄下

htmlhead

!--这里的代码是要放在head之间的--

style type="text/css" media="screen"

#floater {

position: absolute;

width: 90;

visibility: visible;

z-index: 10;

}

--

/style

!--结束,,这里的代码是要放在head之间的--meta http-equiv=content-type content="text/html; charset=gb2312"title自己看吧/title

body

!--这里的代码是要放在body之间的--

div ID="floater" style="left: 590px; top: 158px"

!--这里是放你的搜索栏--

form action="" target="_blank"

table bgcolor="#FFFFFF"trtd

input name=tn type=hidden value=baidu

a href=""img src="" alt="Baidu" align="bottom" border="0"/a

input type=text name=word size=30

input type="submit" value="百度搜索"

/td/tr/table

/form

!--搜索栏结束--

/divscript 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

!--这里的代码是要放在body之间的--

/body/head/html

搜索框的代码怎么写

首先把搜索宽切片下来再CSS样式里面用为背景

body

form action="" method="get"

div class="kuan"input name="" type="text" //div!--搜索框--

div class="an"input name="" type="button" //div!--搜索按钮--

/form

/body

CSS样式根据实际自己调整

style type="text/css"

.kuan input{ width:330px; height:60px; background:background:url(../img/kuan_01.jpg) no-repeat; border:none; float:left}

.an input{ width:120px; height:60px; background:background:url(../img/an_02.jpg) no-repeat;border:none; float:left}

/style

网页设计求悬浮窗代码

{

width:100px;

height:130px;

background:red;

position:absolute;

right:0;

bottom:0;

}

中的position属性值改为fixed。搞定

html制作一个搜索框,代码是什么?

html制作一个搜索框,代码是:testvarNS4=(document.layers);//Whichbrowser?

html的运用范围:

html:即超文本标记语言,它是标准通用标记语言下的一个应用,“超文本”就是指页面内可以包含图片、链接,甚至音乐、程序等非文字元素,超文本标记语言的结构包括“头”部分(Head)、和“主体”部分(Body),其中“头”部提供关于网页的信息,“主体”部分提供网页的具体内容,它包含了许多的功能:

1、HTML语言概述:在WWW上的一个超媒体文档称之为一个页面(page)。作为一个组织或个人在万维网上开始点的页面称为主页Homepage,其中通常包括有指向其他相关页面或其他节点的指针(超级链接)。在逻辑上将视为一个整体的一系列页面的有机集合称为网站(Website或Web)。而Web页面也就是通常所说的网页。

2、HTML规范标准:HTML是一种规范,一种标准,它通过标记符号来标记要显示的网页中的各个部分。网页文件本身是一种文本文件,通过在文本文件中添加标记符,可以告诉浏览器如何显示其中的内容(如:文字如何处理,画面如何安排,图片如何显示等)。浏览器按顺序阅读网页文件,根据标记符解释和其标记的内容,对书写出错的标记将不指出其错误,且不停止其解释执行过程,编制者只能通过显示效果来分析出错原因和出错部位。但需要注意的是,在不同的浏览器,同一标记符可能会有不完全相同的解释,所以会有不同的显示效果。

3、标记语言:HTML之所以称为超文本标记语言,是因为文本中包含了所谓“超级链接”点------就是一种URL指针,通过激活(点击)它,可使浏览器方便地获取新的网页。而这也是HTML能够获得广泛应用的重要的原因之一。

总结:网页的本质就是由许多不同的HTML组成,通过结合使用其他的Web技术(如:脚本语言、CGI、组件等),可以创造出功能强大的网页。因此,HTML是Web编程的基础。

关于网页悬浮搜索框代码和网页悬浮窗代码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/11786.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载