I have this group of spans that are supposed to serve as selectors, so I want them to take up the entire space around them when the user hovers over them, however I have no idea how and could not find an answer to this. please help, here’s my code
*
{
margin:0;
padding:0;
}
.selector {
cursor: pointer;
padding-right: 40px;
padding-left: 20px;
display:inline-block;
}
.link {
background-color:LightGray;
color:black;
padding: 5px;
font-size: 25px;
overflow:hidden;
}
<div class="link"><b>
<span onmouseover= 'style="background-color:white;"' onmouseout= 'style="background-color:LightGray;"' style="color:black;" class="selector">Prehrana</span>
<span onmouseover= 'style="background-color:white;"' onmouseout= 'style="background-color:LightGray;"' style="color:black;" class="selector">Pica</span>
<span onmouseover= 'style="background-color:white;"' onmouseout= 'style="background-color:LightGray;"' style="color:black;" class="selector">Ciscenje </span>
<span onmouseover= 'style="background-color:white;"' onmouseout= 'style="background-color:LightGray;"' style="color:black;" class="selector">Drugo</span>
<span onmouseover= 'style="background-color:white;"' onmouseout= 'style="background-color:LightGray;"' style="color:black;" class="selector">Akcija</span>
</b></div>
the text inside the span is croatian. This is also my first website that I am making with no assistance so don’t make fun of me please.
4
Answers
I solved it by adding
padding-top: 10px
padding-bottom: 10px
margin: -10;
to the selector class
The .link is like the container of all the .selectors, so give it a known height and make it a flex container by setting display to flex
Then make the span’s display be either block or inline-block because they are inline by default – with that you can set their width, height, and all.
You can then set the height of all the span to (100%) of the parent height
Like this
Set link to have a fixed size.
Remove padding specified in link.
Set selector:hover to have 100% height.
I also moved your styles from the html into the css file.
Try this