首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何将div与其父级的顶部对齐,同时保持其内联块行为?

如何将div与其父级的顶部对齐,同时保持其内联块行为?
EN

Stack Overflow用户
提问于 2011-04-16 19:53:48
回答 5查看 278.1K关注 0票数 183

请参阅:http://jsfiddle.net/b2BpB/1/

问:如何使box1和box3与父boxContainer的顶部对齐?

#boxContainerContainer {
  background: #fdd;
  text-align: center;
}

#boxContainer {
  display: inline-block;
  border: thick dotted #060;
  margin: 0px auto 10px auto;
  text-align: left;
}

#box1 {
  width: 50px;
  height: 50px;
  background: #999;
  display: inline-block;
}

#box2 {
  width: 50px;
  height: 100px;
  background: #999;
  display: inline-block;
}

#box3 {
  width: 50px;
  height: 50px;
  background: #999;
  display: inline-block;
}

非常感谢你的帮助。

致谢:这个问题是从https://stackoverflow.com/users/20578/paul-d-waite之前给出的答案派生的:Getting a CSS element to automatically resize to content width, and at the same time be centered

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5686276

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档