When I am hovering over the blocks the color of the numbers are changing but not the literals which are accompany the blocks. I tried ways like "key-selector:hover {color:white}" but it is not working. What can I do to solve my problem and what is the reason for that the common way is not working. Thank you.
.navbar {
display: flex;
list-style: none;
background-color: rgb(77, 55, 120);
margin: 0;
position: fixed;
width: 100%;
gap: 4rem;
height: 50px;
text-align: center;
line-height: 45px;
left: 0;
top: 0;
}
.nav-text {
text-decoration: none;
color: white;
width: auto;
cursor: pointer;
font-size: 18px;
}
.options {
height: auto;
max-height: 313px;
max-width: 750px;
width: auto;
padding-top: 150px;
padding-bottom: 50px;
display: flex;
flex-direction: column;
gap: 15px;
position: sticky;
left: 8rem;
}
.button {
background-color: rgb(226, 226, 226);
height: 418.75%;
width: auto;
padding: 21px 25px 22px 25px;
box-sizing: border-box;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
cursor: pointer;
font-size: 18px;
line-height: 16.8px;
display: block;
position: relative;
top: 0px;
bottom: 0px;
right: 0px;
left: 0px;
}
.text {
margin-left: 4rem;
}
.button:hover {
/*background-color: rgb(116, 181, 218);*/
background-color: rgb(77, 55, 120);
opacity: 0.65;
color: white;
}
#backward:hover,
#forward:hover {
background-color: rgb(77, 55, 120);
color: white;
}
.key-selector {
position: absolute;
top: 50%;
margin-top: -12px;
font-size: 16px;
line-height: 1.5em;
text-align: center;
width: 30px;
display: block;
opacity: 0.6;
border: 1px solid;
border-radius: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
height: 25px;
color: #333;
}
.button-bar {
position: fixed;
bottom: 0;
width: 100%;
display: flex;
margin: 0;
left: 0;
}
.nav-inner {
cursor: pointer;
width: 50%;
text-align: center;
line-height: 83px;
}
#backward {
background-color: rgb(101, 93, 93);
color: white;
}
#forward {
background-color: rgb(191, 191, 191);
}
<ul >
<li ><a href="client.html">Mandant</a></li>
<li ><a href="case.html">Anliegen</a></li>
</ul>
<div >
<div >
<div >
<div >
<span>A</span>
</div>
<div >1</div>
</div>
</div>
<div >
<div >
<div >
<span>B</span>
</div>
<div >2</div>
</div>
</div>
<div >
<div >
<div >
<span>C</span>
</div>
<div >3</div>
</div>
</div>
<div >
<div >
<div >
<span>D</span>
</div>
<div >4</div>
</div>
</div>
<div >
<div >
<div >
<span>E</span>
</div>
<div >5</div>
</div>
</div>
</div>
<div >
<div id="backward">
< Zurück</div>
<div id="forward"> Weiter ></div>
</div>
</div>
CodePudding user response:
Take a look at this example. i have added a couple of lines to your code (lines 96 - 98). I think you get the idea and can change it so it fits what you want to du
.navbar {
display: flex;
list-style: none;
background-color: rgb(77, 55, 120);
margin: 0;
position: fixed;
width: 100%;
gap: 4rem;
height: 50px;
text-align: center;
line-height: 45px;
left: 0;
top: 0;
}
.nav-text {
text-decoration: none;
color: white;
width: auto;
cursor: pointer;
font-size: 18px;
}
.options {
height: auto;
max-height: 313px;
max-width: 750px;
width: auto;
padding-top: 150px;
padding-bottom: 50px;
display: flex;
flex-direction: column;
gap: 15px;
position: sticky;
left: 8rem;
}
.button {
background-color: rgb(226, 226, 226);
height: 418.75%;
width: auto;
padding: 21px 25px 22px 25px;
box-sizing: border-box;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
cursor: pointer;
font-size: 18px;
line-height: 16.8px;
display: block;
position: relative;
top: 0px;
bottom: 0px;
right: 0px;
left: 0px;
}
.text {
margin-left: 4rem;
}
.button:hover {
/*background-color: rgb(116, 181, 218);*/
background-color: rgb(77, 55, 120);
opacity: 0.65;
color: white;
}
#backward:hover,
#forward:hover {
background-color: rgb(77, 55, 120);
color: white;
}
.key-selector {
position: absolute;
top: 50%;
margin-top: -12px;
font-size: 16px;
line-height: 1.5em;
text-align: center;
width: 30px;
display: block;
opacity: 0.6;
border: 1px solid;
border-radius: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
height: 25px;
color: #333;
}
.button:hover .key-selector {
color: white;
}
.button-bar {
position: fixed;
bottom: 0;
width: 100%;
display: flex;
margin: 0;
left: 0;
}
.nav-inner {
cursor: pointer;
width: 50%;
text-align: center;
line-height: 83px;
}
#backward {
background-color: rgb(101, 93, 93);
color: white;
}
#forward {
background-color: rgb(191, 191, 191);
}
<ul >
<li ><a href="client.html">Mandant</a></li>
<li ><a href="case.html">Anliegen</a></li>
</ul>
<div >
<div >
<div >
<div >
<span>A</span>
</div>
<div >1</div>
</div>
</div>
<div >
<div >
<div >
<span>B</span>
</div>
<div >2</div>
</div>
</div>
<div >
<div >
<div >
<span>C</span>
</div>
<div >3</div>
</div>
</div>
<div >
<div >
<div >
<span>D</span>
</div>
<div >4</div>
</div>
</div>
<div >
<div >
<div >
<span>E</span>
</div>
<div >5</div>
</div>
</div>
</div>
<div >
<div id="backward">
< Zurück</div>
<div id="forward"> Weiter ></div>
</div>
</div>
CodePudding user response:
Try using pseudo class for button followed by .key-selector
:
.button:hover .key-selector {
color: white;
}
Here is a snipped, is it what you meant?
.navbar {
display: flex;
list-style: none;
background-color: rgb(77, 55, 120);
margin: 0;
position: fixed;
width: 100%;
gap: 4rem;
height: 50px;
text-align: center;
line-height: 45px;
left: 0;
top: 0;
}
.nav-text {
text-decoration: none;
color: white;
width: auto;
cursor: pointer;
font-size: 18px;
}
.options {
height: auto;
max-height: 313px;
max-width: 750px;
width: auto;
padding-top: 150px;
padding-bottom: 50px;
display: flex;
flex-direction: column;
gap: 15px;
position:sticky;
left: 8rem;
}
.button {
background-color: rgb(226, 226, 226);
height: 418.75%;
width: auto;
padding: 21px 25px 22px 25px;
box-sizing: border-box;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
cursor: pointer;
font-size: 18px;
line-height: 16.8px;
display: block;
position: relative;
top: 0px;
bottom: 0px;
right: 0px;
left: 0px;
}
.text {
margin-left: 4rem;
}
.button:hover {
/*background-color: rgb(116, 181, 218);*/
background-color: rgb(77, 55, 120);
opacity: 0.65;
color: white;
}
.button:hover .key-selector {
color: white;
}
#backward:hover,
#forward:hover {
background-color: rgb(77, 55, 120);
color: white;
}
.key-selector {
position: absolute;
top: 50%;
margin-top: -12px;
font-size: 16px;
line-height: 1.5em;
text-align: center;
width: 30px;
display: block;
opacity: 0.6;
border: 1px solid;
border-radius: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
height: 25px;
color: #333;
}
.button-bar {
position: fixed;
bottom: 0;
width: 100%;
display: flex;
margin: 0;
left: 0;
}
.nav-inner {
cursor: pointer;
width: 50%;
text-align: center;
line-height: 83px;
}
#backward {
background-color: rgb(101, 93, 93);
color: white;
}
#forward {
background-color: rgb(191, 191, 191);
}
<ul class = "navbar">
<li class = "section"><a class = "nav-text" href = "client.html">Mandant</a></li>
<li class = "section"><a class = "nav-text" href = "case.html">Anliegen</a></li>
</ul>
<div class = "options">
<div class = "option">
<div >
<div >
<span>A</span>
</div>
<div >1</div>
</div>
</div>
<div >
<div >
<div class = "key-selector">
<span >B</span>
</div>
<div >2</div>
</div>
</div>
<div >
<div >
<div class = "key-selector">
<span>C</span>
</div>
<div >3</div>
</div>
</div>
<div >
<div >
<div class = "key-selector">
<span >D</span>
</div>
<div >4</div>
</div>
</div>
<div >
<div >
<div class = "key-selector">
<span >E</span>
</div>
<div >5</div>
</div>
</div>
</div>
<div class = "button-bar">
<div class = "nav-inner" id = "backward"> < Zurück</div>
<div class = "nav-inner" id = "forward"> Weiter ></div>
</div>
</div>