O
O
OblivionGM2021-08-26 14:43:41
css
OblivionGM, 2021-08-26 14:43:41

How can I set the background to the full width of the page inside a limited-width block?

How can I set the background for the background block, which is inside the container block, so that the background is the entire width of the page? Below is an example in which I need to do this.

<main class="conteiner">
    <section>
        Определенное кол-во контента
    </section>
    <section class="background">
        Здесь нужно, чтобы было фоновое изображение, и чтобы оно было на всю ширину страницы, а не на ширину 
        указанную в conteiner
    </section>
    <section>
        Определенное кол-во контента
    </section>
</main>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
andand44, 2021-08-26
@OblivionGM

https://css-tricks.com/full-width-containers-limit...
For example, like this

.background {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question