纯HTML / CSS解决方案,可使全身背景可点击

时间:2015-01-07 02:25:27

标签: html css

我想让整个div(占据页面背景)完全可点击,

<div style="position: fixed; top:0px; left:0px; z-index: -1; background: url() center center no-repeat; width: 100%; height:100%;">
    <a href='http://cdn.wonderfulengineering.com/wp-content/uploads/2014/07/background-wallpapers-8.jpg' target='_blank' style="display:block; width: 100%; height: 100%;">
    <img src="http://cdn.wonderfulengineering.com/wp-content/uploads/2014/07/background-wallpapers-8.jpg">
    </a>
</div>

我在身体的开头有这个权利,它确实给出了整个文档的背景,但它完全不可点击,尽管在display:block中提供了全宽和高度。

有一个纯粹的html / css解决方案吗?

1 个答案:

答案 0 :(得分:1)

HTML

<a href="http://cdn.wonderfulengineering.com/wp-content/uploads/2014/07/background-wallpapers-8.jpg">Hello world!!!</a>

CSS

a {
background: url(http://cdn.wonderfulengineering.com/wp-content/uploads/2014/07/background-wallpapers-8.jpg) center center no-repeat;
cursor: pointer;
display: block;
height:100vh;
}