Home:ALL Converter>Cannot change color of letter and border while hovering

Cannot change color of letter and border while hovering

Ask Time:2022-09-20T02:25:22         Author:fujitsu fiji

Json Formatter

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 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 class="button">
      <div class="key-selector">
        <span>A</span>
      </div>
      <div class="text">1</div>
    </div>
  </div>
  <div class="option">
    <div class="button">
      <div class="key-selector">
        <span>B</span>
      </div>
      <div class="text">2</div>
    </div>
  </div>
  <div class="option">
    <div class="button">
      <div class="key-selector">
        <span>C</span>
      </div>
      <div class="text">3</div>
    </div>
  </div>
  <div class="option">
    <div class="button">
      <div class="key-selector">
        <span>D</span>
      </div>
      <div class="text">4</div>
    </div>
  </div>
  <div class="option">
    <div class="button">
      <div class="key-selector">
        <span>E</span>
      </div>
      <div class="text">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>

Author:fujitsu fiji,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/73777774/cannot-change-color-of-letter-and-border-while-hovering
Boguz :

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\n\r\n\r\n.navbar {\n display: flex;\n list-style: none;\n background-color: rgb(77, 55, 120);\n margin: 0;\n position: fixed;\n width: 100%;\n gap: 4rem;\n height: 50px;\n text-align: center;\n line-height: 45px;\n left: 0;\n top: 0;\n}\n\n.nav-text {\n text-decoration: none;\n color: white;\n width: auto;\n cursor: pointer;\n font-size: 18px;\n}\n\n.options {\n height: auto;\n max-height: 313px;\n max-width: 750px;\n width: auto;\n padding-top: 150px;\n padding-bottom: 50px;\n display: flex;\n flex-direction: column;\n gap: 15px;\n position: sticky;\n left: 8rem;\n}\n\n.button {\n background-color: rgb(226, 226, 226);\n height: 418.75%;\n width: auto;\n padding: 21px 25px 22px 25px;\n box-sizing: border-box;\n border-top-left-radius: 5px;\n border-top-right-radius: 5px;\n border-bottom-left-radius: 5px;\n border-bottom-right-radius: 5px;\n cursor: pointer;\n font-size: 18px;\n line-height: 16.8px;\n display: block;\n position: relative;\n top: 0px;\n bottom: 0px;\n right: 0px;\n left: 0px;\n}\n\n.text {\n margin-left: 4rem;\n}\n\n.button:hover {\n /*background-color: rgb(116, 181, 218);*/\n background-color: rgb(77, 55, 120);\n opacity: 0.65;\n color: white;\n}\n\n#backward:hover,\n#forward:hover {\n background-color: rgb(77, 55, 120);\n color: white;\n}\n\n.key-selector {\n position: absolute;\n top: 50%;\n margin-top: -12px;\n font-size: 16px;\n line-height: 1.5em;\n text-align: center;\n width: 30px;\n display: block;\n opacity: 0.6;\n border: 1px solid;\n border-radius: 5px;\n border-top-left-radius: 5px;\n border-top-right-radius: 5px;\n border-bottom-left-radius: 5px;\n border-bottom-right-radius: 5px;\n height: 25px;\n color: #333;\n}\n\n.button:hover .key-selector {\n color: white;\n}\n\n.button-bar {\n position: fixed;\n bottom: 0;\n width: 100%;\n display: flex;\n margin: 0;\n left: 0;\n}\n\n.nav-inner {\n cursor: pointer;\n width: 50%;\n text-align: center;\n line-height: 83px;\n}\n\n#backward {\n background-color: rgb(101, 93, 93);\n color: white;\n}\n\n#forward {\n background-color: rgb(191, 191, 191);\n}\r\n<ul class=\"navbar\">\n <li class=\"section\"><a class=\"nav-text\" href=\"client.html\">Mandant</a></li>\n <li class=\"section\"><a class=\"nav-text\" href=\"case.html\">Anliegen</a></li>\n</ul>\n<div class=\"options\">\n <div class=\"option\">\n <div class=\"button\">\n <div class=\"key-selector\">\n <span>A</span>\n </div>\n <div class=\"text\">1</div>\n </div>\n\n </div>\n\n <div class=\"option\">\n <div class=\"button\">\n <div class=\"key-selector\">\n <span>B</span>\n </div>\n <div class=\"text\">2</div>\n </div>\n\n\n </div>\n\n <div class=\"option\">\n <div class=\"button\">\n <div class=\"key-selector\">\n <span>C</span>\n </div>\n <div class=\"text\">3</div>\n </div>\n\n </div>\n\n <div class=\"option\">\n <div class=\"button\">\n <div class=\"key-selector\">\n <span>D</span>\n </div>\n <div class=\"text\">4</div>\n </div>\n\n </div>\n\n <div class=\"option\">\n <div class=\"button\">\n <div class=\"key-selector\">\n <span>E</span>\n </div>\n <div class=\"text\">5</div>\n </div>\n\n </div>\n</div>\n\n\n<div class=\"button-bar\">\n <div class=\"nav-inner\" id=\"backward\">\n < Zurück</div>\n <div class=\"nav-inner\" id=\"forward\"> Weiter ></div>\n </div>\n\n</div>",
2022-09-19T18:30:14
yy