当我尝试超链接下面的代码时,它似乎弄乱了图像的包装并且只链接了图标而不是整个 flex-container。我试过用 <span>
进行试验元素,但没有取得任何成功。
.flex-container {
padding: 0;
margin: 0;
list-style: none;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: row;
transition: opacity .2s ease-in-out;
flex-wrap: nowrap
}
.flex-item {
text-align: center;
text-decoration: none;
color: #ffffff;
font-family: verdana;
width: 100%;
display: flex;
flex-shrink: 1;
justify-content: center;
align-items: center;
font-size: calc(8px + (26 - 18) * ((100vw - 300px) / (1600 - 300)));
z-index: 10;
flex-wrap: nowrap
}
.flex-item:before {
content: '';
float: left;
padding-top: 100%;
}
.red-box {
background: #fd6f71;
transition: opacity .2s ease-in-out;
opacity: 1;
}
<div class="flex-container">
<div class="red-box flex-item">
<div class="lh-icon"><img src="https://i.imgur.com/NCp8Sst.png"></div>
<a>Placeholder</a>
</div>
</div>
密码本:
最佳答案
自 <a>
元素不能包含 <a>
children ,所以用 <a>
包装整个 .flex-container会失败。只需将占位符的标记从 <a>
更改为至 <span>
.
<a href="http://yourlinkhere.com">
<div class="flex-container">
<div class="red-box flex-item">
<div class="lh-icon"><img src="https://i.imgur.com/IyLYxCc.png"></div>
<span>Placeholder</span>
</div>
</div>
</a>
希望这有帮助:D
关于html - 超链接 <div> 元素的集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60200662/