How to align one element on top of another with css?

0

Hello.

I have this html code:

<p class="titulo">
    <a href="javascript:void(0);">(ABC)</a> Texto de Teste
</p>

It normal looks like this: (ABC) Test Text

How do I make (ABC) over the Test Text and centralized?

So:

    (ABC)
Texto de Teste

Note: I use twitter bootstrap.

    
asked by anonymous 01.06.2017 / 19:10

3 answers

3

You can center the text within the paragraph and put the display:block property on the a element, eg:

p.titulo{
  text-align:center;
}
p.titulo a{
  display:block;
}
<p class="titulo">
    <a href="javascript:void(0);">(ABC)</a> Texto de Teste
</p>
    
01.06.2017 / 19:25
2

You can make an element occupy an entire row by modifying the style (via attribute or CSS). Simply enter% with%. This is the default for div 's, but for links for example the behavior is display: block , so display: inline should suffice in your case.

The element will occupy a whole line ... You can also adjust the length with display: block and alignment with width , text-align , padding etc.     

01.06.2017 / 19:16
1

You need to add a div too.

<p class="titulo">
  <div id="umaDivQualquer">
    <a href="javascript:void(0);">(ABC)</br> Texto de Teste
  </div>
</a>

CSS:

#umaDivQualquer {
  width: 100px;
  height: 50px;
  text-align: center;
}

Young Embrace.

    
01.06.2017 / 19:18