Reputation: 411
I'm trying to nest multiple class using sass. I want to use hover to show a button. My scss is as follows:
.item{
border-bottom: 1px dotted #ccc;
text-indent: 50px;
height: 81%;
padding: 2px;
text-transform: capitalize;
color: green;
.Button{
visibility: hidden;
&:hover{
visibility: visible;
}
}
}
this is shown in css as :
.item {
border-bottom: 1px dotted #ccc;
text-indent: 50px;
height: 81%;
padding: 2px;
text-transform: capitalize;
color: green; }
.item .Button {
visibility: hidden; }
.item .Button:hover {
visibility: visible; }
The hover property is not working here.
Upvotes: 1
Views: 689
Reputation: 470
try this:
.item{
border-bottom: 1px dotted #ccc;
text-indent: 50px;
height: 81%;
padding: 2px;
text-transform: capitalize;
color: green;
&:hover {
.btn {
visibility: visible;
}
}
.btn{
visibility: hidden;
}
}
Upvotes: 0
Reputation: 863
Since the button is already hidden, I would put the visible property on the item:hover instead.
How the SCSS should look:
.item {
border-bottom: 1px dotted #ccc;
text-indent: 50px;
height: 81%;
padding: 2px;
text-transform: capitalize;
color: green;
.Button {
visibility: hidden;
}
&:hover .Button {
visibility: visible;
}
}
.item {
border-bottom: 1px dotted #ccc;
text-indent: 50px;
height: 81%;
padding: 2px;
text-transform: capitalize;
color: green;
}
.item .Button {
visibility: hidden;
}
.item:hover .Button {
visibility: visible;
}
<div class="item">
Hover Item Class
<button class="Button">button shows</button>
</div>
Upvotes: 2