How can I make an entire div a link, but also have other links inside?

前端 未结 6 1274
广开言路
广开言路 2021-01-21 00:46

I have a div. I want it to link somewhere when you click on it, but I also want to put other links inside it, so when you click on the other links you\'re redirected to one plac

6条回答
  •  独厮守ぢ
    2021-01-21 01:09

    You could use positioning to display a link within anoter link/container.

    I have created an example, it's not perfect but will give you an idea.

    https://codepen.io/MartynMc/pen/gRyqXL

    HTML:

    
    

    CSS:

    .container {
      width: 250px;
      height: 250px;
      border: 2px solid;
      position: relative;
    }
    .link1 {
      display: block;
      width: 100%;
      height: 100%;
      position: absolute;
    }
    .link2 {
      display: block;
      top: 75px;
      left: 50px;
      font-size: 24pt;
      position: absolute;
      width: 150px;
      height: 50px;
      border: 2px solid red;
      text-align: center;
      line-height: 50px;
    }
    

提交回复
热议问题