How do I code SCSS to show something like left image on hover.
如何编码SCSS以在悬停时显示左图像。
HTML.
HTML。
<div class="col-md-4 col-sm-6">
<div class="reference__content--item">
<img src="{{ asset($reference->photo->file) }}">
</div>
</div>
SCSS
SCSS
.reference {
&__content {
margin-bottom: 30px;
&--item {
background-color: transparent;
img {
margin-top: 30px;
&:hover {
background-color: #0000AA;
}
}
}
}
}
1 个解决方案
#1
1
I have checked your code, normally it will work now.
我检查了你的代码,通常它现在可以正常工作。
html:
HTML:
<div class="col-md-4 col-sm-6">
<div class="reference__content--item">
<img src="{{ asset($reference->photo->file) }}">
<div class="overlay"></div>
</div>
</div>
scss:
SCSS:
.reference {
&__content {
&--item {
position: relative;
display: inline-block;
img {
margin-top: 30px;
&:hover {
background-color: #0000AA;
}
}
.overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 255, 0.6);
z-index: 9999;
color: white;
visibility: hidden;
}
// you have to use just the "&" sign instead of reference__content--item
&:hover>.overlay {
visibility: visible;
}
}
&--title {
font-size: 18px;
}
}
}
#1
1
I have checked your code, normally it will work now.
我检查了你的代码,通常它现在可以正常工作。
html:
HTML:
<div class="col-md-4 col-sm-6">
<div class="reference__content--item">
<img src="{{ asset($reference->photo->file) }}">
<div class="overlay"></div>
</div>
</div>
scss:
SCSS:
.reference {
&__content {
&--item {
position: relative;
display: inline-block;
img {
margin-top: 30px;
&:hover {
background-color: #0000AA;
}
}
.overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 255, 0.6);
z-index: 9999;
color: white;
visibility: hidden;
}
// you have to use just the "&" sign instead of reference__content--item
&:hover>.overlay {
visibility: visible;
}
}
&--title {
font-size: 18px;
}
}
}