Text on button makes line break automatically, taking space for the rest text

Asked

Viewed 36 times

1

Good afternoon, I am building a project where in the upper right corner has a button written "Login" but for some reason this text is breaking line automatically, and there is space for the rest text.

Code:

@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed&display=swap');
            *{
                margin: 0;
                padding: 0;
            }
            body{
                background: #333;
            }
            div.background{
                min-height: 100%;
                background: url('https://i.ibb.co/tzmQZfz/original.jpg') rgba(0, 0, 0, 0.4);
                background-size: cover;
                background-blend-mode: multiply;
            }
            div.menuTop{
                display: flex;
                justify-content: space-between;
                flex-direction: row;
            }
            div.menuTop .title{
                align-self: center;
                width: 100%;
                margin-top: 3px;
                color: red;
                font-family: 'Roboto Condensed', sans-serif;
                font-size: 45px;
                text-align: center;
                text-shadow: 2px 2px 4px #000000;
            }
            .btnStartSession{
                padding: 10px 80px;
                margin-top: 5px;
                margin-right: 5px;
                border-radius: 3px;
                background: #333;
                outline: none;
                cursor: pointer;
                border: 0px;
                color: #FFF;
                font-size: 18px;
            }
            .btnStartSession:hover{
                background: #222;
            }
<html>
    <head>
        <title>IMM Flix | Home</title>
        <meta charset="utf-8" />
    </head>
    <body>
        <div class="background">
            <div class="menuTop">
                <p class="title">IMM | FLIX</p>
                <button class="btnStartSession">Iniciar Sessão</button>
            </div>
            <div class="sugestionsReg">
                <p>Todos as suas series/filmes onde e quando quiser!</p>
                <p>Experimente gratis durante 1 mês</p> 
            </div>
        </div>
    </body>
</html>

1 answer

1


The text is breaking inside the BTN pq the Pai container has display: flex; to correct this puts a min-width in BTN and slightly decreases the padding

Another option is to put white-space: nowrap; in the button class .btnStartSession

inserir a descrição da imagem aqui

@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed&display=swap');
*{
    margin: 0;
    padding: 0;
}
body{
    background: #333;
}
div.background{
    min-height: 100%;
    background: url('https://i.ibb.co/tzmQZfz/original.jpg') rgba(0, 0, 0, 0.4);
    background-size: cover;
    background-blend-mode: multiply;
}
div.menuTop{
    display: flex;
    justify-content: space-between;
    flex-direction: row;
}
div.menuTop .title{
    align-self: center;
    width: 100%;
    margin-top: 3px;
    color: red;
    font-family: 'Roboto Condensed', sans-serif;
    font-size: 45px;
    text-align: center;
    text-shadow: 2px 2px 4px #000000;
}
.btnStartSession {
    padding: 10px 30px;
    margin-top: 5px;
    margin-right: 5px;
    border-radius: 3px;
    background: #333;
    outline: none;
    cursor: pointer;
    border: 0px;
    color: #FFF;
    font-size: 18px;
    min-width: 200px;
}
.btnStartSession:hover{
    background: #222;
}
<div class="background">
    <div class="menuTop">
        <p class="title">IMM | FLIX</p>
        <button class="btnStartSession">Iniciar Sessão</button>
    </div>
    <div class="sugestionsReg">
        <p>Todos as suas series/filmes onde e quando quiser!</p>
        <p>Experimente gratis durante 1 mês</p> 
    </div>
</div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.