1

Я применила псевдокласс :hover, но когда навожу мышку на список, у меня двигается весь список. Можете подробно объяснить в чем ошибка, чтобы в будущем не допускать её снова.

* {
  margin: 0 auto;
  padding: 0 auto;
}

body {
  width: 100% height: 100vh;
}

a {
  text-decoration: none;
}

li {
  list-style: none;
}

.clearfix {
  clear: both;
}

.container {
  width: 1170px
}

.header-bg {
  height: 94px;
  background-color: white;
}

.menu {
  float: right;
  margin-top: 42px;
}

.list-link {
  color: #868686;
}

.list-link:hover {
  color: white;
}

.list-link:active {
  color: white;
}

.menu li {
  float: left;
  padding-right: 40px;
  font-size: 13.5px;
  font-family: "Lato";
  text-transform: uppercase;
  text-align: center;
}

.menu li:hover {
  border-radius: 3px;
  width: 80px;
  height: 35px;
  background-color: #ffbb42;
}
<header>
  <div class="container">
    <div class="clearfix">
      <div class="header">
        <div class="menu">
          <ul>
            <li><a href="#" class="list-link">Home</a></li>
            <li><a href="#" class="list-link">Service</a></li>
            <li><a href="#" class="list-link">About us</a></li>
            <li><a href="#" class="list-link">Pricing Table</a></li>
            <li><a href="#" class="list-link">How it work</a></li>
            <li><a href="#" class="list-link">Happy Clients</a></li>
            <li><a href="#" class="list-link">Contact Us</a></li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</header>

0

1 ответ 1

2

* {
  margin: 0;
  padding: 0;
  list-style-type: none;
}

body,
html {
  height: 100%;
}

a {
  text-decoration: none;
}

header {
  padding: 15px 0;
}

.container {
  max-width: 1170px;
  margin: 0 auto;
}

.list-link {
  color: #868686;
}

.menu ul {
  display: flex;
}

.menu li:not(:first-child) {
  margin-left: 10px;
}

.menu li a {
  font-size: 13.5px;
  font-family: "Lato";
  text-transform: uppercase;
  text-align: center;
  border-radius: 3px;
  padding: 10px 5px;
  white-space: nowrap;
  display: block;
  transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

.menu li:hover .list-link {
  color: white;
  background-color: #ffbb42;
}
<header>
  <div class="container">
    <div class="header">
      <div class="menu">
        <ul>
          <li><a href="#" class="list-link">Home</a></li>
          <li><a href="#" class="list-link">Service</a></li>
          <li><a href="#" class="list-link">About us</a></li>
          <li><a href="#" class="list-link">Pricing Table</a></li>
          <li><a href="#" class="list-link">How it work</a></li>
          <li><a href="#" class="list-link">Happy Clients</a></li>
          <li><a href="#" class="list-link">Contact Us</a></li>
        </ul>
      </div>
    </div>
  </div>
</header>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.