使用div结构创建表
我正在尝试完成这种布局。
请注意文本如何始终垂直居中。我想使用 div 的垂直对齐来实现这一点。
注意:块没有特定的高度。使用 top:50%
等属性或定位无法实现精确居中。
I'm trying to accomplish this sort of layout..
Notice how the text is always vertical centered. I want to achieve that using vertical-align with divs.
Note: Blocks don't have a specific height. Using properties like top:50%
or positioning won't achieve exact centering.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题是图像。解决方法是将图像和文本内容分成两个单独的“单元格”,这将正确确定对齐方式。这是示例 - 我必须为容器设置一些宽度,但因为它们充当表格单元格他们会根据内容进行调整(正如我试图证明的那样)
The problem is the image. The work around is to separate the image and the text content into two separate 'cells' which will correctly determine the alignment. Here is an example - I've had to set some width's for the containers but since they are acting as table cells they will adjust according to content (as I have tried to demonstate)
你这里有一个错误。 ul 前面不应有点,因为它不是一个类。其余看起来不错。
You have an error here. ul should not be preceded by dot since its not a class .Rest looks fine.
尝试以下操作,我编辑了您上面提供的 jsfiddle 链接,并设法获得与上面包含的图片类似的布局。
Try the following, I edited the jsfiddle link you gave above and managed to get a similar layout to the picture you included above.