#css #fron
tend
CSSda Divni Markazlash
Html struktura:
<div class="container">
<div class="centered-div">Mar
l
angan kontent</div>
<
;/div>
1?? Flexbox yordamida markazlash:
.container {
display: flex;
justify-content: center;
l
ign-items: center;
hei
ght: 100vh;
}
2?? Grid yordamida markazlash:
.container {
display: grid;
l
ace-items: center;
height:
100vh;
}
3?? Absolyut yordamida markazlash:
.container {
position: relative;
height: 100vh;
}
.centered-div {
position: absolute;
top: 50%;
left: 5
transform: translate(-50%, -5
0%);
}
4?? Margin Auto yordamida markazlash:
// Gorizontal markazlash uchun, margin: auto
.centered-
{
width: 50%;
margin: 0 auto;
}
5?? Inline-block bilan markazlash:
// Inline yoki inline-block elementlari uchun
.container {
text-align: center;
line-height: 100vh;
}
.centered-div {
display: inline-block;
vertical-align: middle;
line-height: normal;
}
@frontend
Обсуждение 1
Обсуждение не доступно в веб-версии. Чтобы написать комментарий, перейдите в приложение Telegram.
Обсудить в Telegram