gpt4 book ai didi

javascript - 当 CSS3 列溢出时重复 HTML 标题

转载 作者:行者123 更新时间:2023-11-28 17:17:33 25 4
gpt4 key购买 nike

我正在尝试找到一种方法,让我的 HTML header 在我的 CSS3 列溢出时重复我的 HTML header 。

假设我有 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;
}

fiddle :http://jsfiddle.net/ap9stajy/2/

最佳答案

尝试数这样的单词

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')
}

如果单词是 > of 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;

}

关于javascript - 当 CSS3 列溢出时重复 HTML 标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28332079/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com