I
I
Ivan Tabakerka2020-02-03 20:36:27
css
Ivan Tabakerka, 2020-02-03 20:36:27

How to make two neighboring tags interact with each other?

There are two adjacent blocks, is it possible to make the body respond when hovering over the navigation block using CSS?

<main>
    <nav></nav>
    <section></section>
  </main>

nav
  width: 50px
  position: fixed
  top: 0
  bottom: 0
  left: 0
  background: #151515
nav:hover
  width: 150px
section
  position: fixed
  top: 0
  right: 0
  bottom: 0
  left: 70px
  background: #151515
nav:hover section
  left: 170px

5e3859b8b368d507755296.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Bogachev, 2020-02-03
@IvanTabakerka

You probably need to use "+":

nav:hover + section
  left: 170px

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question