IE中背景有图片不能不选择元素
Cannot not choose the element in IE if there is an image at the background
抱歉又是我问同样的问题,因为我没有把问题说清楚,所以昨天没有人帮我澄清我的困惑。这里是codepen(好像不能在ie8中打开)。我想拖动'move-obj',但是如果有图像,它在IE浏览器(8,9,10)中不起作用background.How 我可以让这个演示在 IE8 以上的 IE 浏览器上运行吗?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.wrap{
position: relative;
width: 100%;
height: 100%;
background-color: #f0f0f0;
padding: 10%;
}
.wrap-inside{
position: absolute;
top: 100px;
left: 100px;
width: 502px;
height: 502px;
border: 1px solid #ddd;
}
.move-obj{
cursor: move;
position: absolute;
top: 100px;
left: 100px;
width: 100px;
height: 100px;
border: 1px solid blue;
background-color: rgba(0,0,0,0);//if I add the background, it will work correctly in IE9 IE10
filter: progid:DXImageTransform.Microsoft.gradient(startcolorstr=#00000000,endcolorstr=#00000000); //doesn't work in IE8
}
.bg{
top: 102px;
left: 102px;
width: 500px;
height: 500px;
position: absolute;
}
</style>
</head>
<body>
<div class="wrap">
<img class="bg" src="images/img1.jpg" alt="">//if this tag remove, it work correctly
<div class="wrap-inside">
<div class="move-obj"></div>
</div>
</div>
<script src="js/jquery.min.js"></script>
<script>
$('.move-obj').on('mousedown',function(e){
var start_x = e.pageX;
var start_y = e.pageY;
var $that = $(this);
var t_left = parseInt($that.css('left'));
var t_top = parseInt($that.css('top'));
$('.wrap-inside').on('mousemove',function(e){
$that.css({
left: t_left + e.pageX - start_x,
top: t_top + e.pageY - start_y
});
}).on('mouseup',function(e){
$(this).off('mousemove');
});
});
</script>
</body>
</html>
只需为 .move-obj
背景设置透明图像,或者尝试将透明图像设置为 url(about:blank)
也应该有效。
抱歉又是我问同样的问题,因为我没有把问题说清楚,所以昨天没有人帮我澄清我的困惑。这里是codepen(好像不能在ie8中打开)。我想拖动'move-obj',但是如果有图像,它在IE浏览器(8,9,10)中不起作用background.How 我可以让这个演示在 IE8 以上的 IE 浏览器上运行吗?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.wrap{
position: relative;
width: 100%;
height: 100%;
background-color: #f0f0f0;
padding: 10%;
}
.wrap-inside{
position: absolute;
top: 100px;
left: 100px;
width: 502px;
height: 502px;
border: 1px solid #ddd;
}
.move-obj{
cursor: move;
position: absolute;
top: 100px;
left: 100px;
width: 100px;
height: 100px;
border: 1px solid blue;
background-color: rgba(0,0,0,0);//if I add the background, it will work correctly in IE9 IE10
filter: progid:DXImageTransform.Microsoft.gradient(startcolorstr=#00000000,endcolorstr=#00000000); //doesn't work in IE8
}
.bg{
top: 102px;
left: 102px;
width: 500px;
height: 500px;
position: absolute;
}
</style>
</head>
<body>
<div class="wrap">
<img class="bg" src="images/img1.jpg" alt="">//if this tag remove, it work correctly
<div class="wrap-inside">
<div class="move-obj"></div>
</div>
</div>
<script src="js/jquery.min.js"></script>
<script>
$('.move-obj').on('mousedown',function(e){
var start_x = e.pageX;
var start_y = e.pageY;
var $that = $(this);
var t_left = parseInt($that.css('left'));
var t_top = parseInt($that.css('top'));
$('.wrap-inside').on('mousemove',function(e){
$that.css({
left: t_left + e.pageX - start_x,
top: t_top + e.pageY - start_y
});
}).on('mouseup',function(e){
$(this).off('mousemove');
});
});
</script>
</body>
</html>
只需为 .move-obj
背景设置透明图像,或者尝试将透明图像设置为 url(about:blank)
也应该有效。