左对齐文本,右对齐CSS中的图像 [英] Left align text AND right align image in CSS

查看:232
本文介绍了左对齐文本,右对齐CSS中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对CSS有点新,我有一个问题,我似乎无法解决。我想在我的页面上有一系列的div(堆叠在另一个之上),每个都应该包含一些文本和一个或多个图像。

I am somewhat new to CSS and I have a problem that I can't seem to solve. I would like to have a series of divs on my page (stacked one on top of the other) and each of them should contain some text, and one or more images.

特别是,我想让文本左对齐,在中间垂直对齐,图像应该右对齐,div的高度应该基于图像的高度(这可以是可变的)

In particular, I would like the text to be left aligned, and vertically aligned in the middle, and the images should be right aligned, and the height of the div should be based upon the height of the images (which can be variable).

基本上每个div应该是这样的:

Basically each of the divs should look like so:

到目前为止,我已经能够获得上面列出的一个或多个要求,时间。这是真的可能与纯CSS,或者我应该只是退出浪费我的时间和使用表?

So far I have been able to get one or more of the requirements listed above, but never all of them at the same time. Is this actually possible with pure CSS, or should I just quit wasting my time and use a table?

推荐答案

您的解决方案chek this link http://jsfiddle.net/8mQc4/15/

Hi i have a solution for you chek this link http://jsfiddle.net/8mQc4/15/.

它基于使用一些属性:

float and vertical-align.

此代码允许img灵活的高度和宽度,并且他的容器中心垂直文本。有更多的大文本或图片。

This code allows flexible height and width of img, and also his container center vertically de text.Just try with more large texts or images.

这篇关于左对齐文本,右对齐CSS中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆