css - 当 parent 与中心对齐时,将 child 向左对齐

标签 css

是否可以在父级居中时让子级向左对齐?

我有元素列表。父 block 应居中对齐,子 block 应向左对齐。

enter image description here

现在我也可以将 child 对齐到中心 - JSFIDDLE

.parent {
  text-align: center;
}
.child {
  width: 100px;
  height:100px;
  margin:10px;
  display:inline-block;
  background:#e0e0e0;
}

最佳答案

请试试

.child {
  width: 100px;
  height:100px;
  margin:10px;
  float: left;
  text-align: left;
  background:#e0e0e0;
}

fiddle - http://jsfiddle.net/Dgdhr/82/

关于css - 当 parent 与中心对齐时,将 child 向左对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35473045/

相关文章:

Android 浏览器对 HTML 和 CSS 的限制

html - 具有可变页面内容的侧边栏高度

html - 分页内联边距

css - 悬停效果数据字母文本对齐

css - SCSS : Pass multiple classes to a mixin

html - 如何为特定输入类型文本添加 css

html - 我们可以多次拥有 css 样式属性吗?

css - 按钮在滚动时固定,但不在元素下方

HTML-工具提示相对于鼠标指针的位置

html - 我如何居中一个div?