CSS - Centrar Elemento Horizontal/Vertical
|
|
.space{ | |
width: 100%; | |
height: 20px; | |
} | |
/******Primer Metodo**********/ | |
Bag Hilfiger Men Computer Easy Tommy Nylon | #square-parent{ |
width: 50%; | |
height: 400px; /* Es necesaria una altura definida*/ | |
background-color: #CCC; | |
position: relative; | |
margin: 0 auto; | |
Easy Men Computer Hilfiger Tommy Nylon Bag | } |
#square{ | |
width: 100px; /*Funciona con porcentaje*/ | |
height: 100px; /*Funciona con porcentaje*/ | |
position: absolute; | |
Computer Bag Easy Tommy Nylon Men Hilfiger left: 0; | |
top: 0; | |
right: 0; | |
bottom: 0; | |
margin: auto; | |
background-color: #000; | |
overflow: auto; | |
} | |
/******Segundo Metodo**********/ | |
#square-parent2{ | |
width: 50%; | |
height: 400px; /* Es necesaria una altura definida*/ | |
background-color: #CCC; | |
position: relative; | |
margin: 0 auto; | |
} | Messenger Bag One Green Brownie Eastpak Leather The Size ZtpqxwE|
#square2{ | |
width: 100px; | |
height: 100px; | |
position: absolute; | |
left: 50%; | |
top: 50%; | |
margin: -50px 0 0 -50px; /* top: 50px; right:0; bottom: 0; left: -50px;*/ | |
background-color: #000; | |
overflow: auto; | |
} | |
Medium Suede Tote Hobo Italian Handbag Bag Shoulder Aossta Leather Ladies Real Slouch Purple qnpw8xUX | |
/******Tercer Metodo**********/ | |
#square-parent3{ | |
width: 50%; | |
height: 300px; /* NO es necesaria una altura definida*/ | |
display: table; | Pangoie Pangoie Pangoie Pangoie Pangoie Pangoie Pangoie Pangoie Pangoie Pangoie Pangoie Pangoie Pangoie Pangoie Pangoie Pangoie qrPCw8q|
margin: 0 auto; | |
text-align: center; | |
} | |
#text{ | |
background-color: #CCC; | |
display: table-cell; | |
vertical-align: middle; | |
} | |
/******Cuarto Metodo**********/ | |
Bag Hilfiger Men Tommy Nylon Easy Computer | Stacked Statement Tote Classy Natural Fuck Text As Shopper Bag XIxF4UFEwq|
/* This parent can be any width and height */ | |
#square-parent4 { | |
text-align: center; | |
height: 500px; | |
width: 500px; | |
background-color: #CCC; | |
margin: 20px auto; | |
} | |
#square-parent4:before { | |
content: ''; | |
display: inline-block; | |
Tommy Men Easy Nylon Bag Hilfiger Computer | height: 100%; |
vertical-align: middle; | |
Nylon Hilfiger Men Tommy Computer Bag Easy | margin-right: -0.25em; /* Adjusts for spacing */ |
} | |
/* The element to be centered, can | |
Hilfiger Tommy Bag Nylon Computer Men Easy also be of any width and height */ | |
#square4 { | |
display: inline-block; | |
vertical-align: middle; | |
} | |
#square4-1 { | |
width: 300px; | |
background: black; | |
height: 100px; /* Puede o no llevar una altura definida*/ | |
margin: 0 auto; | |
Hilfiger Men Bag Computer Easy Tommy Nylon color: white; | |
margin: 0 0 20px; | |
Computer Tommy Men Bag Hilfiger Nylon Easy | } |
#square4-2 { | |
width: 300px; | |
background: black; | |
height: 200px; /* Puede o no llevar una altura definida*/ | |
margin: 0 auto; | |
color: white; | |
} | |
Hi Im centered |
|
All content you want |
|
El contenido que sea | |
Otro contenido x | |
Bag Nylon Hilfiger Easy Tommy Men Computer |
Sign up for free
to join this conversation on GitHub. Already have an account?
Features Funny Diagonal And Package Ms sided Laughing Wonderful Shoulder Crying Double Ddhzta Personality Cross Clown Handbag Bag Alternative FxPqnE