Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cannot change color of letter and border while hovering

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>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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 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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading