M
M
malen1322021-11-19 10:51:24
css
malen132, 2021-11-19 10:51:24

How to refer to the upper class?

Good afternoon, how to refer to the class: .main

<div class="columns">
     <div class="main"></div>
     <div class="sidebar-additional"></div>
  </div>


There is a block where:
.main {
   width: 70%;
}
.sidebar-additional{
   width: 30%;
}


How to make .main width 100% if there is no .sidebar-additional class on the page ?
It turns out main is at the top, but the neighbor is sidebar-additional.

Tried like this:
.sidebar-additional ~ .main {
    width: 800px !important;
}

or with + , nothing comes out...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2021-11-19
@malen132

.main {
  width: 70%;
}
.main:last-child {
  width: 100%;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question