【发布时间】:2022-02-15 16:26:57
【问题描述】:
以下是我正在开发的网站的一些 HTML 代码:
.container {
display: flex;
flex-direction: row;
position: relative;
top: 10%;
width: 25vw;
min-width: 428px;
height: auto;
padding: 15px;
justify-content: left;
align-items: center;
background-color: white;
}
.container a {
color: black;
margin-left: 10px;
text-decoration: none;
transition: all ease-in-out 0.25s;
}
.container a h2:hover {
text-decoration: underline;
}
.container a img {
width: 100px;
height: auto;
}
.container + .container {
margin-top: 20px;
}
<body>
<div class="main">
<h1>Contact</h1>
<p>In need of a commission? Do you just want to talk? Let me know by shooting me an email or DMing me on Instagram.</p>
<div class="container">
<a href="https://www.instagram.com/bellapfisterphotography" target="_blank"><img src="./insta.png"></a>
<a href="https://www.instagram.com/bellapfisterphotography" target="_blank"><h2>@bellapfisterphotography</h2></a>
</div>
<div class="container">
<a href="mailto:mail@gmail.com"><img src="./email.png"></a>
<a href="mailto:mail@gmail.com"><h2>mail@gmail.com</h2></a>
</div>
</div>
由于某种原因,我应用到容器元素的下划线过渡没有按预期运行。任何有关解决此问题或解释为什么会发生这种情况的帮助将不胜感激。
【问题讨论】:
-
使用
<h2>代替<a>被认为是无效的HTML。