1
resposta

Como aumentar o meu footer?

Olá, tenho um body com 1200 px para centralizar a pagina, porem quero que meu footer seja maior que 1200 porque ele vai ter um background diferente que vai pegar de uma ponta a outra. Como posso fazer isso? usei um width no footer de 100 vw, porem o navegador cria uma barra de rolagem pra esquerda.

CSS

*{
    margin: 0;
    padding: 0;
}

body{
    max-width: 1200px;
    margin: 0 auto;
}


header{

}

.container{
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header_nav{
    display: flex;
    justify-content: space-around;

}

.header_nav a{
    margin-left: 20px;
    text-decoration: none;
    border: 1px solid black;
    padding: 0.32em;

}

.sobre{
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin: 20px 0;
}

.para-todos{
    margin-right: 10px;
}

.img1{
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.img1 .flor{
    max-width: 590px;
}

.img1 .folha{
    max-width: 590px;
}

.img3{
    display: flex;
    justify-content: space-between;
}
.img3 img{
    max-width: 300px;
}


footer{
    display: flex;
    padding: 30px;
    width: 100vw;
    margin-top: 30px;
    background-color: red;
    justify-content: center;
}

footer p{
    margin-left: -30px;
}

HTML

<!DOCTYPE html>
<html lang="pt">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css\style.css">
    <link rel="stylesheet" href="css\style-responsive.css">
    <title>Display</title>
</head>
<body>
        <header>
            <div class="container">
                <h1>
                    <a href="">Logo</a>
                </h1>

                <nav class="header_nav">
                    <a href="">Home</a>
                    <a href="">Quem somos</a>
                    <a href="">Serviços</a>
                    <a href="">Contato</a>
                </nav>
        </div>
        </header>

        <section class="sobre">
            <div class="para-todos">
            <h1>Para todos</h1>
            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, 
                when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap 
                into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum 
                passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
            </div>    

            <div>
            <h1>Sendo todos</h1>
            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, 
               when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap 
               into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum 
               passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
            </div>

        </section>

        <section class="img1">
            <img src="img/flowers-g528d6e865_1920.jpg" alt="" class="flor">

            <img src="img/leaves-gc44114865_1920.jpg" alt="" class="folha">
            <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC</p>
        </section>

        <section class="sobre">
            <div class="para-todos">
            <h1>Para todos</h1>
            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, 
</p>
            </div>    

            <div>
            <h1>Sendo todos</h1>
            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been</p>
            </div>

        </section>

        <article class="img3">
            <img src="img/flowers-g528d6e865_1920.jpg" alt="">
            <img src="img/leaves-gc44114865_1920.jpg" alt="">
            <img src="img/castle-g52030eb28_1920.jpg" alt="">
        </article>

        <footer>
            <p>Desenvolvido por MarcãoDevv</p>
        </footer>
</body>
</html>
1 resposta

Para fazer isso, você pode usar a propriedade CSS min-width no seu elemento footer para especificar uma largura mínima que seja maior do que a largura do seu body. Isso fará com que o footer tenha uma largura maior do que a do body, permitindo que o background se estenda por toda a largura da página.

Aqui está um exemplo de código CSS que você pode usar para alcançar esse efeito: body { width: 1200px; margin: 0 auto; /* centraliza o body */ }

footer { min-width: 1400px; /* largura mínima do footer / background-color: #333; / cor de fundo do footer / color: #fff; / cor do texto do footer / padding: 20px; / espaçamento interno do footer */ }

Em relação a rolagem lateral, o problema pode estar ocorrendo porque a largura total do seu footer é maior do que a largura da janela do navegador, o que faz com que seja criada uma barra de rolagem horizontal.