Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Biel.

centralizar o texto na div

Recommended Posts

centralizar o texto na div
Boa tarde a todos. Direto ao ponto.
Pessoal abaixo temos dois exemplos css. Quero centralizar o texto na div _1_coluna e _4_coluna.
Lembrando que o número de caracteres que está na div _1_coluna e _4_coluna pode aumentar ou diminuir
conforme a necessidade. Ou seja independentemente de quantos caracteres tem na div , gostaria que o texto ficasse
sempre no centro da div conforme vocês podem ver na tabela
<style type="text/css">
#_1_coluna{width:120px;float:left; height:100px; text-align:left; background:#990; padding:40px 0px 0px 0px;  }
#_2_coluna{width:auto; float:left; height:100px; line-height:100px; margin:0px 0px 10px 10px; text-align:center; background:#9C3;}
#_3_coluna{width:auto; float:left; height:100px; line-height:100px; margin:0px 0px 0px 10px; text-align:center; background:#999;}
</style>

<style type="text/css">
#_4_coluna{width:120px;float:left; height:100px; text-align:left; background:#990; padding:40px 0px 0px 0px; }
#_5_coluna{width:auto; float:left; height:100px; line-height:100px; margin:0px 0px 10px 10px; text-align:center; background:#9C3;}
#_6_coluna{width:auto; float:left; height:100px; line-height:100px; margin:0px 0px 0px 10px; text-align:center; background:#999;}
</style>

<div id="_1_coluna">aprendiz </div>
<div id="_2_coluna"><img src="tete.jpg" width="74" height="100px" /></div>
<div id="_3_coluna"><a href="excluir.php"><b>Excluir</b></a></div>

<br><br><br><br><br><br><br>

<div id="_4_coluna">O segredo para aprender é estudar. </div>
<div id="_5_coluna"><img src="tete.jpg" width="74" height="100px" /></div>
<div id="_6_coluna"><a href="excluir.php"><b>Excluir</b></a></div>

Veja que independentemente de quantos caracteres tem na 1 coluna, o texto sempre fica no centro. Pessoal quero fazer o mesmo com css

<table width="340" border="1" cellpadding="3" cellspacing="3">

  <tr>
    <td width="119" height="145">aqui tem um número maior de caracteres e o texto está no centro</td>
    <td width="113"><img src="tete.jpg" width="74" height="100px" /></td>
    <td width="70"><a href="excluir.php"><b>Excluir</b></a></td>
  </tr>
</table>

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

Bom, não sei se é exatamento isso que você precisa... mas se n for pode remover.

<!DOCTYPE html>
<html>
<head>
<title>HTML5, CSS3 and JavaScript demo</title>
  <style>
    div.texto{
      width: 200px;
      height: 200px;
      background-color:#0000FF ;
      text-align: center;
    }
    
  </style>
 </head>
<body>
<!-- Start your code here -->

  <div class="texto"><p>Centralizando o texto</p></div>

<!-- End your code here -->
</body>
</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.