简体   繁体   中英

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

on this page i have a background image on the <body> tag and i'm wondering if it's possible to add a link to it so it clicks through to something.

if this isn't possible, how would i add a wrapper <div> that would be hyperlinked?

<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%;

check if this is what you want

 <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";
})

fiddled here

try this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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