and*_*dms 2 html css css-animations
当我尝试超链接下面的代码时,它似乎弄乱了图像的包装并且只链接了图标而不是整个 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;
}Run Code Online (Sandbox Code Playgroud)
<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>Run Code Online (Sandbox Code Playgroud)
代码笔:
小智 6
由于<a>元素不能包含<a>子元素,因此将整个 .flex-container 包装起来<a>会失败。只需将占位符的标签从 更改<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>
Run Code Online (Sandbox Code Playgroud)
希望这有帮助:D