2、网页浮动窗口对应的部分代码如下所示:
<html>
<style>
.img_wd{
font-size:30padding-top:20px
text-align:leftpadding-left:70pxline-height:40px
background:url(110.jpg) top center no-repeat
width:252pxheight:127pxline-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: absolutevisibility :hiddenpadding:0px" onmouseover="clearInterval(interval)" onmouseout="interval = setInterval('changePos()', delay)" align="middle">
<span style="CURSOR:handcolor:redfont-weight:boldfont-align:centerfont-size:12pxpadding-left:0px" onclick="clearInterval(interval)fdck.style.visibility = 'hidden'img.style.visibility = 'hidden'">隐藏</span>
<div id="fdck" style="width:100%height:100%font-align:centervisibility:visibleborder:0pxbackground-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 = 1yPos = 0}
if (yPos >= (height - Hoffset)) {yon = 0
yPos = (height - Hoffset)}
if (xon) {xPos = xPos + step}
else {xPos = xPos - step}
if (xPos <0) {xon = 1xPos = 0}
if (xPos >= (width - Woffset)) {xon = 0xPos = (width - Woffset)}
}
function start() {
img.style.visibility = "visible"
interval = setInterval('changePos()', delay)}
start()
</script>
5、在此需要说明一点,需要将以上所有代码(包括JS脚本)全部放置在<body>和</body>之间。
6、最后查看一下浮动窗口的效果,会发现浮动窗口在网页中不断的移动,当鼠标悬停其上时会停止移动,点击“隐藏”按钮将自动隐藏悬浮窗口。
项目终于提测了,耗时3周,经历了从前端小白到前皮搭端小菜的过程。在开发过程中,踩到了很多坑,但是通过万能的baidu和google,这些坑都被填平了,尽管填坑的材料可能不是最优。现在纪录一下踩到的坑和填坑的过程。
Requirement:
实现一个在图片底部用阴影展示码握绝title的样式。如果把图片和标题迟姿各看作一个div,那要实现的就是让一个div悬浮(或重叠)在另一个div上面。
Implementation:
1、按顺序输入的div是从上到下排列的。
效果:
2、为了让over悬浮在under上,要使用到position属性。
效果:
3、没有什么问题是一个div解决不了的。
效果:
好了。今天就纪录到这里,如果找到更好的方法会继续补充。加油!新的一周已经开始!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)