0

我需要一些帮助...我应该如何使用两个图像和一个文本块标记布局,该文本块分为 2 列不同宽度,其中由于其中一个图像,第二列开始低于第一列?这是我的布局草图:

我希望我足够明确地描述了我的问题。

PS:真的可以吗?

4

1 回答 1

0

CSS3 有一个解决方案,但它还不是标准的,并且在旧版浏览器中不起作用这里是一个链接http://www.css3.info/preview/multi-column-layout/

可能最好的主意是以某种方式使用 javascript。将所有文本放在第一列并测试高度,然后将部分文本移动到下一列,直到您有相等的列或直到第一列处于所需的高度。

另一种方法是具有预定义的比例,例如(第一列中的 2/3 和第二列中的 1/3)。然后使用字符数根据比例拆分文本。这并不准确,您可以使用类似于上述方法的方法根据溢出属性找到确切的宽度,但字符应该平均为正确的长度。

这种方法非常简单,看起来像

var txt='Column text...';
var len=txt.length;
var chars=Math.floor(len*.67);
//Assuming you want 2/3 of the text in the first column
document.getElementById('col1').innerHTML=txt.substring(0,chars);
document.getElementById('col2').innerHTML=txt.substring(chars);
//Notice that this could split in the middle of a word so you would need to do
//some checking for the nearest space and the change the break to there.
//Also you could then use the previous method to adjust it if you want something really accurate
于 2012-04-09T18:15:07.293 回答