Skip to content

Instantly share code, notes, and snippets.

@UlyssesAlves
Last active September 27, 2023 23:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UlyssesAlves/f8dbe2267a0742de3ccaa81aca34a66f to your computer and use it in GitHub Desktop.
Save UlyssesAlves/f8dbe2267a0742de3ccaa81aca34a66f to your computer and use it in GitHub Desktop.
Como centralizar uma <div> dentro de outra <div> usando CSS.
#divExterna {
width: 100%;
}
/* Primeira alternativa para centralizar a DIV. */
#divInterna {
width: 50%;
margin: 0 auto;
background-color: yellow;
}
/* Segunda alternativa para centralizar a DIV. */
#divInterna {
display: table;
margin: 0 auto;
background-color: yellow;
}
<html>
<head>
<title>Centralizando uma DIV dentro de outra DIV</title>
<link rel="stylesheet" type="text/css" href="centralizando_divs.css"></link>
</head>
</body>
<div id="divExterna">
<div id="divInterna">
Conteúdo da DIV interna.
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment