【发布时间】:2021-02-12 16:50:02
【问题描述】:
当我使用全局标记<a> 编写此代码时,链接 id 已定义并出现在鼠标所在的任何位置的底部。
<a class="link" href="opencl/toto.htm">
<div class="enve d-flex">
<div class="picture">
<figure class="figure" style="background-image: url('images/desert.jpg');">
</figure>
</div>
<div class="description">
<span class="keywords">keyword1 - keyword2</span>
<h6 class="title">
************************** Title 1
</h6>
<div class="stats">
<span>
<span class="pstat">
<svg class="stats-icon" viewBox="0 0 24 24">
<path
d="M17 4h3v16h-3zM5 14h3v6H5zm6-5h3v11h-3z"
></path>
<title>Difficulté</title>
</svg>
<span class="stat-text">
<span>Facile</span>
</span>
</span>
</span>
<span>
<span class="pstat">
<svg class="stats-icon" viewBox="0 0 24 24">
<path
d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
></path>
<path
d="M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"
></path>
<title>Durée</title>
</svg>
<span class="stat-text">
<span>20 heures</span>
</span>
</span>
</span>
</div>
<div class="explication">
Explanation about that
</div>
</div>
</div>
</a>
结果正常:
但是现在,我想要一个包含所有 div 图片的图片链接,以及另一个涵盖第二列(描述)的链接,但似乎容器(flexbox、bootstrap)和我没有解决这个问题的解决方案(当鼠标悬停在图片或第二列时,两个链接都必须出现在页面底部(就像 href 一样)).. 可以这样做吗?
代码与结果不符:
<div class="enve d-flex">
<a class="link" href="opencl/toto.htm">
<div class="picture">
<figure class="figure" style="background-image: url('images/desert.jpg');">
</figure>
</div>
</a>
<a class="link" href="opencl/titi.htm">
<div class="description">
<span class="keywords">keyword1 - keyword2</span>
<h6 class="title">
************************** Title 1
</h6>
<div class="stats">
<span>
<span class="pstat">
<svg class="stats-icon" viewBox="0 0 24 24">
<path
d="M17 4h3v16h-3zM5 14h3v6H5zm6-5h3v11h-3z"
></path>
<title>Difficulté</title>
</svg>
<span class="stat-text">
<span>Facile</span>
</span>
</span>
</span>
<span>
<span class="pstat">
<svg class="stats-icon" viewBox="0 0 24 24">
<path
d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
></path>
<path
d="M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"
></path>
<title>Durée</title>
</svg>
<span class="stat-text">
<span>20 heures</span>
</span>
</span>
</span>
</div>
<div class="explication">
Explanation about that
</div>
</div>
</a>
</div>
两个链接的结果都不好:
CSS 代码(实际上是 scss)
.picture{
background-color: rgb(0, 131, 143);
flex-shrink: 0;
align-self: flex-start;
width: 40%;
position: relative;
max-width: 270px;
.figure{
width: 100%;
height: auto;
margin: 0;
display: block;
padding: 0;
padding-bottom: 56.25%;
background-size: cover;
//background-color: #e0e0e0;
background-position: center;
}
}
.enve{
box-shadow: 0px 2px 1px -1px rgba(0,0,0,0.2),0px 1px 1px 0px rgba(0,0,0,0.14),0px 1px 3px 0px rgba(0,0,0,0.12);
padding: 16px;
margin-bottom: 16px;
}
.enve:hover{
transition: box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
}
.description{
font-size: 1rem;
line-height: 1.625rem;
margin: 0 0 0 16px;
width: 100%;
.title{
font-size: 1rem;
font-weight: 700;
line-height: 1.625rem;
}
}
.link{
color:inherit;
text-decoration: none;
display: block;
&:hover{
color:inherit;
text-decoration: none;
}
}
.stats{
box-sizing: border-box;
font-size: 1rem;
line-height: 1.625rem;
margin-bottom: 8px;
.pstat{
margin: 0;
margin-right: 24px;
.stats-icon{
font-size: 1.5rem;
width: 18px;
height: 18px;
margin-right: 8px;
margin-bottom: 3px;
vertical-align: middle;
}
}
}
当我清除类 d-flex 时,结果还可以,但当然必须用行替换列……我想要列……
【问题讨论】:
-
请同时添加相应的css。似乎是样式问题。
-
@MincedMeatMole 我已经添加了css代码
标签: html jquery bootstrap-4 sass flexbox