導航:首頁 > 編程語言 > 點擊圖片彈出層代碼

點擊圖片彈出層代碼

發布時間: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了,你可以試試

閱讀全文

與點擊圖片彈出層代碼相關的資料

熱點內容
怎麼開通移動4g網路 瀏覽:130
岳陽微信公司 瀏覽:96
win10如何從備份中恢復出廠設置密碼 瀏覽:659
什麼軟體修改wifi密碼錯誤 瀏覽:582
遇見不安全網站怎麼辦 瀏覽:251
哪個app有慶余年電視劇 瀏覽:420
iphone5s視頻時很黑 瀏覽:601
js獲取埠號 瀏覽:347
手機短息發的鏈接病毒蘋果手機 瀏覽:724
win10專業忘記家庭組密碼 瀏覽:176
南寧applestore幾樓 瀏覽:296
java字元串怎麼初始化 瀏覽:349
醫美哪個app好 瀏覽:768
代碼編程和機器人編程哪個好 瀏覽:875
90版本男法 瀏覽:796
win10桌面字體難看 瀏覽:848
三菱fx5u支持哪些編程 瀏覽:7
優酷在文件夾在哪裡 瀏覽:91
趣列印的數據文件是什麼 瀏覽:871
linuxjava程序 瀏覽:483

友情鏈接