How do I place a text on the same line as a bootstrap Collapse button?

Asked

Viewed 205 times

-1

    <div>
    <p>TROCO</p>
    <button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
        ...
    </button>

    <div class="collapse" id="collapseExample">
        <div class="card card-body">
            texto que aparece quando pressiono o botão
        </div>
    </div>
</div>

The code is this one, I wanted the text "CHANGE" to appear in the same line as the button, when I open the page they are in different lines, and if I put the text inside the < button> the text goes inside the button... Does anyone know what’s going on??

1 answer

0


The <p> is an element block, ie it occupies the entire line (100%) of the width of the screen, so the button is not on the side. One way to fix this is for example to change the <p> by a <span>

inserir a descrição da imagem aqui

See how it looks in the code:

 <div>
    <span>TROCO</span>
    <button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
        ...
    </button>

    <div class="collapse" id="collapseExample">
        <div class="card card-body">
            texto que aparece quando pressiono o botão
        </div>
    </div>
</div>

  • 1

    Thank you very much guy!!!

  • Hey, I’m using the span right, so when I try to edit the text within the span, I can’t change the style of it, change the font and the positioning, you can tell me how it does??

  • @Jingas cara isso eh o básico do CSS, o melhor que vc tem a fazer eh entrar no Youtube e procurar um curso de CSS, la tem várias e eh de graça

Browser other questions tagged

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