当CSS3列溢出时重复HTML标题

时间:2015-02-04 21:45:55

标签: javascript jquery html5 css3 multiple-columns

当我的CSS3列溢出时,我正试图找到一种方法让我的HTML标题重复我的HTML标题。

假设我有3列,当列文本转到新列时,它会显示“标题”,标题也会移动。

HTML:

<div>
<h2>Heading</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>

CSS:

div p {
    columns: 3;
    -webkit-columns: 3;
    -moz-columns: 3;
}

小提琴:http://jsfiddle.net/ap9stajy/2/

1 个答案:

答案 0 :(得分:1)

尝试计算像这样的单词

var words =$('.col').text().split(' ');

    var center=($('#wrap').width()/3)+25;
    var right=Number((center+center)+45);
if( words.length <=4){

}
if(words.length >= 4  ){

    $('#h2').attr('style','margin-left:'+center+'px')
}

如果单词是&gt;你会设置保证金。 4个

HTML

<div id="wrap" >
    <h2 id="h2">Heading</h2>
<p class="col">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a 
</p>
</div>

CSS

.col {
    columns: 3;
    -webkit-columns: 3;
    -moz-columns: 3;

}