① 如何用css js 或 jq实现在不是背景的图片上面加既透明又简便的遮罩层
图片一个div1,遮罩层一个div2,将div2绝对定位到div1上,设置div2的透明度即可。
② 怎么用js做出,点击一个按钮,弹出一个遮罩层,5秒后自己关闭.的效果
<!DOCTYPEhtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>Document</title>
<style>
#cover{
position:fixed;
top:0;
left:0;
height:100%;
width:100%;
background-color:rgba(0,0,0,0.3);
display:none;
z-index:1000;
}
</style>
</head>
<body>
<button>这是一个按钮</button>
<divid="cover">这是一个遮罩</div>
<script>
varbtn=document.getElementsByTagName('button')[0];
btn.addEventListener('click',function(){
varcover=document.getElementById('cover');
cover.style.display='block';
setTimeout(function(){
cover.style.display='none';
},5000)
})
</script>
</body>
</html>
③ 用JS或者JQ写多个点击预览和点击上传功能,点击预览会弹出一个遮罩层来显示图片
.onwindow{
position:fixed;
top:43%;
left:43%;
z-index:99;
width:250px;
height:135px;
background-color:rgba(255,255,255,1);
display:none;
border:2pxsolidred;
border-radius:15px;
padding:10px;
}
.plank{
position:fixed;
top:0;
bottom:0;
left:0;
right:0;
background-color:rgba(255,255,255,0.8);
width:100%;
display:none;
}
<divclass="onwindow">//显示窗口
<image>...........
</div>
<divclass="plank"></div>//背景
varhide=()=>{$(".onwindow").hide();$(".plank").hide();}
varshow=()=>{$(".onwindow").show();$(".plank").show();}
④ js如何实现点击图片弹出窗口并放大这张图片,弹出的窗口有半透明遮罩层效果,弹出的窗口不跳页面
通过JS代码 document.getElementById('divID').style.etElementById('divID').style.display = 'none'。函数可以实现。
⑤ js弹出div并显示遮罩层
弹出div显示遮罩层的效果,想必大家都有见到过吧,下面有个示例,大家可以参考下
代码如下:
//--------------------弹出层-------------------
//popDivId:弹出层div的ID
//dragDivId:用于拖动div的ID
//isShowMask:是否显示遮罩层
function
popDivShow(popDivId,
dragDivId,
isShowMask)
{
if
(isShowMask)
{
creatMask(popDivId);
}
var
oWins
=
document.getElementById(popDivId);
var
oWins_title
=
document.getElementById(dragDivId);
var
bDrag
=
false;
var
disX
=
disY
=
0;
oWins.style.display
=
"block";
oWins_title.onmousedown
=
function(event)
{
var
event
=
event
||
window.event;
bDrag
=
true;
disX
=
event.clientX
-
oWins.offsetLeft;
disY
=
event.clientY
-
oWins.offsetTop;
this.setCapture
&&
this.setCapture();
return
false;
};
document.onmousemove
=
function(event)
{
if
(!bDrag)
return;
var
event
=
event
||
window.event;
var
iL
=
event.clientX
-
disX;
var
iT
=
event.clientY
-
disY;
var
maxL
=
document.documentElement.clientWidth
-
oWins.offsetWidth;
var
maxT
=
document.documentElement.clientHeight
-
oWins.offsetHeight;
iL
=
iL
<
0
?
0
:
iL;
iL
=
iL
>
maxL
?
maxL
:
iL;
iT
=
iT
<
0
?
0
:
iT;
iT
=
iT
>
maxT
?
maxT
:
iT;
oWins.style.marginTop
=
oWins.style.marginLeft
=
0;
oWins.style.left
=
iL
+
"px";
oWins.style.top
=
iT
+
"px";
return
false;
};
document.onmouseup
=
window.onblur
=
oWins_title.onlosecapture
=
function()
{
bDrag
=
false;
oWins_title.releaseCapture
&&
oWins_title.releaseCapture();
};
}
//
隐藏弹出层
function
popDivHidden(popDivId)
{
var
oWins
=
document.getElementById(popDivId);
oWins.style.display
=
"none";
window.parent.document.body.removeChild(window.parent.document.getElementById("maskDiv"));
}
//
获取弹出层的zIndex
function
getZindex(popDivId)
{
var
popDiv
=
document.getElementById(popDivId);
var
popDivZindex
=
popDiv.style.zIndex;
return
popDivZindex;
}
//
创建遮罩层
function
creatMask(popDivId)
{
//
参数w为弹出页面的宽度,参数h为弹出页面的高度,参数s为弹出页面的路径
var
maskDiv
=
window.parent.document.createElement("div");
maskDiv.id
=
"maskDiv";
maskDiv.style.position
=
"fixed";
maskDiv.style.top
=
"0";
maskDiv.style.left
=
"0";
maskDiv.style.zIndex
=
getZindex(popDivId)
-
1;
maskDiv.style.backgroundColor
=
"#333";
maskDiv.style.filter
=
"alpha(opacity=70)";
maskDiv.style.opacity
=
"0.7";
maskDiv.style.width
=
"100%";
maskDiv.style.height
=
(window.parent.document.body.scrollHeight
+
50)
+
"px";
window.parent.document.body.appendChild(maskDiv);
maskDiv.onmousedown
=
function()
{
window.parent.document.body.removeChild(window.parent.document.getElementById("maskDiv"));
};
}
⑥ 用js实现图片中的效果
<script>
for(vari=0;i<5;i++){
for(varj=0;j<8-i*2;j++){
document.write("&"+"nbsp;");
}
for(varj=0;j<i*2+1;j++){
document.write("*&"+"nbsp;");
}
document.write("<"+"br>");
}
</script>
⑦ 如何用css或js jq在不是背景的图片上面加一层即透明又渐变得遮罩层
ie下面高版本的渐变又透明的才行。没法透明,可以考虑使用透明png。
rgba最后面的那个1可以改为0.8试试看,就变成透明的了。。
#box{width:200px;height:200px;overflow:hidden;position:relative;}
#boxspan{
display:block;width:100%;height:100%;position:absolute;top:0;left:0;
background-image:linear-gradient(bottom,rgba(0,0,0,1)0%,rgba(255,255,255,1)100%);
background-image:-o-linear-gradient(bottom,rgba(0,0,0,1)0%,rgba(255,255,255,1)100%);
background-image:-moz-linear-gradient(bottom,rgba(0,0,0,1)0%,rgba(255,255,255,1)100%);
background-image:-webkit-linear-gradient(bottom,rgba(0,0,0,1)0%,rgba(255,255,255,1)100%);
background-image:-ms-linear-gradient(bottom,rgba(0,0,0,1)0%,rgba(255,255,255,1)100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#000000,endColorstr=#ffffff,grandientType=1);
}
<divid="box">
<imgsrc="https://ss3..com/-fo3dSag_xI4khGko9WTAnF6hhy/news/q=100/sign=/.jpg">
<span></span>
</div>