繁体   English   中英

如何在HTML正文标签上添加到背景图片的链接

[英]how do i add a link to a background image on html body tag

在此页面上,我在<body>标记上具有背景图像,并且我想知道是否可以向其添加链接,以便单击该链接。

如果这不可能,我将如何添加将被超链接的包装器<div>

<body id="index">
</body>

body#index {
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-image: url(//) !important;
  background-size: cover;
  background-repeat: no-repeat;
  background-color: transparent !important;
  background-position: center;
  width: 100%;
  height: 100%;

检查这是否是你想要的

 <body id="index">

    </body>

的CSS

body#index {

    background-color: red !important;

    width:100vw;

    height: 100vh;

}

jQuery的

$('body').click(function () {
    location.href="http://www.google.com";
})

在这里摆弄

尝试这个

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM