gpt4 book ai didi

html - 链接在 DIV 上但不在内容上

转载 作者:太空宇宙 更新时间:2023-11-03 21:10:42 25 4
gpt4 key购买 nike

我在 <div> 上设置了一个链接但是 <div> 的所有元素也成为链接。有什么线索可以删除子项的格式吗?

enter image description here

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

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

div.hotel-preview:hover {
background-color: aliceblue;
}
<a href="@Url.Action("Hotel", "Home", new { id = hotel.IdHotel})">
<div class="hotel-preview">
...
</div>
</a>

最佳答案

我假设您想删除超链接的下划线,您只需添加 text-decoration: none; 到您的标签

<!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>

关于html - 链接在 DIV 上但不在内容上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47236016/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com