<div id="description">
  <h2>Приклад 1: зміна елемента після наведення курсору</h2>
  <p>У цьому прикладі ми показуємо, як за допомогою функції <code>calc()</code> можна змінювати властивості елемента при наведенні курсору. Після наведення курсору на елемент, його ширина зменшується.</p>
</div>

<div id="result">
  <div class="box"></div>
</div>
#description {
  background-color: #f5f5f5;
  padding: 20px;
  font-family: Arial, sans-serif;
  margin-bottom: 20px;
}

#result {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
}

.box {
  width: calc(200px - 20px);
  height: 200px;
  background-color: #4285f4;
  transition: width 0.3s ease;
}

.box:hover {
  width: calc(150px - 20px);
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.