codeing or artist ?
记得大学第一节编程课,教授说,"如果一件事儿有对错,那么是科学。如果有美丑好坏,那么是艺术。" 一个能顺利运行还能让人阅读时体验思维美妙的代码,就是艺术和科学的结合。能运行的程序并不是好程序,能当作文章来读的才是。在我看来代码是一种特殊的文体,程序猿其实会写诗。
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		img{border:none;display:block;width:120px;height:120px;}
		.arrow{width:200px;height:200px;position:absolute;top:30px;left:30px;border:3px solid #000000;display:block;}
	</style>
</head>
<body>
	<img src="https://g-search1.alicdn.com/img/bao/uploaded/i4/imgextra/i4/155650308168019538/TB2v65la5GO.eBjSZFjXXcU9FXa_!!0-saturn_solar.jpg_580x580Q90.jpg">
	<a href="#" class="arrow"></a>
</body>
</html>

 

 

黑框是整个a标签,图片与a标签重叠处无法点击,小手消失,IE10以下都如此,IE11没有测试。而且无论你给图片或是a标签套多少div,设置z-index,都无效。

我们再试试把a标签改成div试试看。

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		img{border:none;display:block;width:120px;height:120px;}
		.arrow{width:200px;height:200px;position:absolute;top:30px;left:30px;border:3px solid #000000;cursor:pointer;}
	</style>
</head>
<body>
	<img src="https://g-search1.alicdn.com/img/bao/uploaded/i4/imgextra/i4/155650308168019538/TB2v65la5GO.eBjSZFjXXcU9FXa_!!0-saturn_solar.jpg_580x580Q90.jpg">
	<div class="arrow"></div>
</body>
</html>

 

测试结果与a标签一样,鼠标移到图片与div重叠处,小手消失。

 

bug的解决方案:

我的方法是给绝对定位元素透明背景色:background:rgba(0,0,0,0); 这可以解决ie8以上的bug

可惜的是ie8以下无解决方案。

不要妄想用filter: progid:DXImageTransform.Microsoft.Gradient(startColorstr=#88000000,endColorstr=#88000000);

也不要妄想用background:#ffffff; opacity:0;,因为这会使元素内的内容全部看不见。

posted on 2017-01-07 18:04  codeing-or-artist-??  阅读(2996)  评论(0编辑  收藏  举报