链接DIV而不是内容

时间:2017-11-11 08:39:43

标签: html css

我在#include <stdio.h> int main(int arg, char *argv[]){ char c = 0; long blank = 0; long tab = 0; while((c=getchar())!= EOF){ if(c == ' '){ ++blank; } if(c != ' '){ if(blank>1){ printf("%c", ' '); blank = 0; printf("%c", c); } else{ printf("%c", c); } } } //end of while return 0; } 上设置了一个链接,但<div>的所有元素也成了链接。 有什么线索我可以从孩子那里删除格式吗?

enter image description here

底部<div>处于翻转模式。

&#13;
&#13;
<div>
&#13;
div.hotel-preview {
  border-style: solid;
  padding: 0px 10px 10px 10px;
  margin-bottom: 20px;
}

div.hotel-preview:hover {
  background-color: aliceblue;
}
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:3)

我假设您要删除超链接的下划线,只需将text-decoration: none;添加到代码

即可

&#13;
&#13;
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <style>
    div.hotel-preview {
      border-style: solid;
      padding: 0px 10px 10px 10px;
      margin-bottom:20px;
    }

    div.hotel-preview:hover {
      background-color: aliceblue;
    }
    
    .href-wrapper {
      text-decoration: none;
    }
  </style>
</head>
<body>

  <a class="href-wrapper" href="/">
     <div class="hotel-preview">
       <h1>Matterhorn</h1>
       
       <p>Lieu: Brig</p>
       <h4>Contact</h4>
       <p>+41279220001</p>
       <p>info@matterhorn.ch</p>
     </div>
  </a>
  
</body>
</html>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

text-decoration: none提供给<a>,例如:

a {
  text-decoration: none;
}

请看下面的代码段:

&#13;
&#13;
div.hotel-preview {
  border-style: solid;
  padding: 0px 10px 10px 10px;
  margin-bottom: 20px;
}

div.hotel-preview:hover {
  background-color: aliceblue;
}

a {
  text-decoration: none;
}
&#13;
<a href="@Url.Action("Hotel", "Home", new { id = hotel.IdHotel})">
  <div class="hotel-preview">
    ...
  </div>
</a>
&#13;
&#13;
&#13;

希望这有帮助!