导航:首页 > 编程语言 > 点击图片弹出层代码

点击图片弹出层代码

发布时间:2023-06-20 06:11:08

㈠ 如何在一张图片的若干个热点中添加弹出层代码,就是淘宝的鼠标经过切换图片的特效。

PS可以,图片做成GIF的格式,这个去网络,有个添加注释。

js如何实现点击图片弹出窗口并放大这张图片,弹出的窗口有半透明遮罩层效果,弹出的窗口不跳页面

通过JS代码 document.getElementById('divID').style.etElementById('divID').style.display = 'none'。函数可以实现。

㈢ 求html代码,点击按钮弹出层,再次点击关闭层

首先你要写好两条CSS,用以切换控制按钮样式(以下代码中省略宽高等声明):

.button{background:url(images/1.jpg)centerno-repeat;}/*默认样式*/
.button-hover{background-image:url(images/2.jpg);}/*鼠标悬停及弹出层时样式*/

然后用JS来控制属性:

varoBtn=document.getElementById('btn');//假设按钮的id为btn
varoDiv=document.getElementById('div');//假设弹出层的id为div
//鼠标悬停
oBtn.onmouseover=function(){
oBtn.className='buttonbutton-hover';
}
//鼠标移出
oBtn.onmouseout=function(){
oBtn.className='button';
}
//点击按钮
oBtn.onclick=function(){
if(oDiv.style.display=='none'){//如果层是隐藏的
oDiv.style.display='block';
oBtn.className='buttonbutton-hover';
}else{//如果层是显示的
oDiv.style.display='none';
oBtn.className='button';
}
}

用jQuery的话代码如下:

varoBtn=$('#btn');
varoDiv=$('#div');
oBtn.hover(function(){
$(this).addClass('button-hover');
},function(){
$(this).removeClass('button-hover');
}).click(function(){
if(oDiv.is(':hidden')){
oDiv.show();
$(this).addClass('button-hover');
}else{
oDiv.hide();
$(this).removeClass('button-hover');
}
});

㈣ 网页代码中鼠标移到图片某个区域自动弹出另一张小图的代码怎么编辑

使用纯CSS即可实现全部效果,代码也很简单。

原理:hover触发CSS临近选择器

所需工具:DW(用来给图片画热区),PS(算出弹出层的top和left偏移值)

我在Demo里画了三个热区(位置如下图),你用鼠标悬停到上面即可看到效果。

㈤ 点击一个div图层,在其上面弹出另一个div图层,用js怎么实现

两个div先写好,一个先隐藏,点击后更改其属性,让其显示

<!doctypehtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>Document</title>
<style>
.outer{
position:relative;
height:300px;
width:500px;
background-color:#097df3;
}

.d1{
display:none;
position:absolute;
height:200px;
width:300px;
top:50px;
left:100px;
background-color:#FF6C00;
}
</style>
</head>
<body>
<divclass="outer"onclick="fn()">
<divclass="d1"></div>
</div>
<script>
functionfn(){
document.getElementsByClassName('d1')[0].style.display="block";
}
</script>
</body>
</html>

javascript或jQuery实现自动弹出层可自动关闭源代码,如何实现

<style>
html,body{margin:0;padding:0;width:100%;height:100%;font-size:36px;}
#bak{display:none;position:fixed;left:0;top:0;width:100%;height:100%;background-color:rgba(0,0,0,0.5)}
#box{position:absolute;left:50%;top:50%;width:400px;height:240px;margin-left:-200px;margin-top:-120px;background-color:#fff}
</style>
<spanid="s1">10</span>秒后会自动弹出层
<divid="bak">
<divid=box>
<spanid="s2">20</span>秒后会自动关闭层
</div>
</div>
<script>
$(function(){
vars=10;
functionshowLayer(){
setTimeout(function(){
$("#s1").text(--s);
if(s){
showLayer();
}else{
$("#bak").show();
s=20;
functionhideLayer(){
setTimeout(function(){
$("#s2").text(--s);
if(s){
hideLayer();
}else{
$("#bak").hide();
}
},1000);
}
hideLayer();
}
},1000);
}
showLayer();
});
</script>

如果不需要计数,那就很简单了(只列出js代码了):

<script>
$(function(){
setTimeout(function(){
$("#bak").show();
setTimeout(function(){
$("#bak").hide();
},20000);
},10000);
});
</script>

㈦ 求点击弹出层的html代码~

var isIe = (document.all) ? true : false;
//设置select的可见状态
function setSelectState(state) {
var objl = document.getElementsByTagName('select');
for (var i = 0; i < objl.length; i++) {
objl[i].style.visibility = state;
}
}
function mousePosition(ev) {
if (ev.pageX || ev.pageY) {
return { x: ev.pageX, y: ev.pageY };
}
return {
x: ev.clientX + document.body.scrollLeft - document.body.clientLeft, y: ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
//弹出方法
function showMessageBox(wTitle, content, pos, wWidth) {
closeWindow();
var bWidth = parseInt(document.documentElement.scrollWidth);
var bHeight = parseInt(document.documentElement.scrollHeight);
if (isIe) {
setSelectState('hidden');
}
var back = document.createElement("div");
back.id = "back";
var styleStr = "top:0px;left:0px;position:absolute;background:#666;width:" + bWidth + "px;height:" + bHeight + "px;";
styleStr += (isIe) ? "filter:alpha(opacity=0);" : "opacity:0;";
back.style.cssText = styleStr;
document.body.appendChild(back);
showBackground(back, 50);
var mesW = document.createElement("div");
mesW.id = "mesWindow";
mesW.className = "mesWindow";
mesW.innerHTML = "<div class='mesWindowTop'><table width='100%' height='100%'><tr><td>" + wTitle + "</td><td style='width:1px;'><input type='button' onclick='closeWindow();' style='font-size:12px;cursor:pointer;' title='关闭窗口' class='close' value='关闭' /></td></tr></table></div><div class='mesWindowContent' id='mesWindowContent'>" + content + "</div><div class='mesWindowBottom'></div>";
styleStr = "left:" + (((pos.x - wWidth) > 0) ? (pos.x - wWidth) : pos.x) + "px;top:" + (pos.y) + "px;position:absolute;width:" + wWidth + "px;";
mesW.style.cssText = styleStr;
document.body.appendChild(mesW);
}
//让背景渐渐变暗
function showBackground(obj, endInt) {
if (isIe) {
obj.filters.alpha.opacity += 1;
if (obj.filters.alpha.opacity < endInt) {
setTimeout(function() { showBackground(obj, endInt) }, 5);
}
} else {
var al = parseFloat(obj.style.opacity); al += 0.01;
obj.style.opacity = al;
if (al < (endInt / 100))
{ setTimeout(function() { showBackground(obj, endInt) }, 5); }
}
}
//关闭窗口
function closeWindow() {
if (document.getElementById('back') != null) {
document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
}
if (document.getElementById('mesWindow') != null) {
document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
}
if (isIe) {
setSelectState('');
}
}
//测试弹出
function testMessageBox(ev, ob) {
var objPos = mousePosition(ev);

messContent = "<div style='text-align:center;filter:alpha(opacity=60);'><img src='" + ob + "' width='600' height='400' /></div>";
showMessageBox('', messContent, objPos, 620);
}
在前台调用:
onclick="testMessageBox(event,'图片的路径');"
图片路径你比如说在C:\a.jpg,你就可以把路径填进去,这样就OK了,你可以试试

阅读全文

与点击图片弹出层代码相关的资料

热点内容
前端postjson数据 浏览:462
plc初次编程如何清理原有程序 浏览:204
苹果6plus手机美版序列号 浏览:6
c语言怎么做成app 浏览:501
u盘共享文件能中病毒吗 浏览:941
腾讯版权视频文件加密什么意思 浏览:632
编程里f4是什么意思 浏览:627
帝国时代2scx文件 浏览:658
什么酷的app 浏览:59
自学手机编程哪里好 浏览:637
怎么把很多文件夹里 浏览:892
文件夹中的文件按照excel进行分类 浏览:967
如何利用网络学英语 浏览:986
word如何删除单页页眉 浏览:712
服装设计数据报错会损失多少 浏览:791
魅族主题文件在哪个文件夹 浏览:957
vbnet读取xlsx文件 浏览:257
word2003公式编号右对齐 浏览:223
word文件夹怎么样可以全选 浏览:658
在大一编程跟不上怎么办 浏览:742

友情链接