[英]How to center a div vertically and horizontally with a checkbox on the top corner of parent div
[英]how to horizontally center multiple div's in a parent div
我正在嘗試創建一個包含多個div的控件,並且所有div都是水平居中對齊的。 如下所示。
我能夠使用float:left
css屬性浮動每個div。 給出這樣的東西
但是div總是留給他們的父母。
我有一個替代解決方案使用javascript來定位每個div但我想使用CSS。 是否有可能使用CSS實現這一目標。
提前致謝
這可能會做你想要的:
HTML:
<div class="parent">
<div class="child">Element 1</div>
<div class="child">Element 2</div>
</div>
CSS:
.child {
display: inline-block;
}
.parent {
text-align: center;
}
和小提琴 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.