gpt4 book ai didi

javascript - Readmore Js 只 chop div 容器而不 chop 文本

转载 作者:行者123 更新时间:2023-11-28 15:15:58 26 4
gpt4 key购买 nike

Readmore Js 只折叠 div block 而不折叠文本。请帮助我 chop 文本和 div 容器,而不仅仅是 div。非常感谢

enter image description here enter image description here

<html>
<head>
<script src="jquery.min.js"></script>
<script src="readmore.js"></script>
<link rel="stylesheet" href="w32.css"
</head>
<body>
<div class="w3-container w3-round w3-border w3-grey" style="width: 600px; margin-top: 20px; margin-left: 300px">
<p class="readmore">London is the most populous city in the United Kingdom
with a metropolitan area of over 13 million inhabitants.
with a metropolitan area of over 13 million inhabitants.
with a metropolitan area of over 13 million inhabitants.
with a metropolitan area of over 13 million inhabitants.
with a metropolitan area of over 13 million inhabitants.
with a metropolitan area of over 13 million inhabitants
with a metropolitan area of over 13 million inhabitants
with a metropolitan area of over 13 million inhabitants
with a metropolitan area of over 13 million inhabitants
</p>
<script type="text/javascript">
$(".readmore").readmore({
});
</script>
</body>
</html>

最佳答案

我会添加一些简单的 CSS 来解决这个问题。 overflow 属性阻止内容扩展到超过其父级的大小。

.readmore {
overflow: hidden;
}

演示:

https://jsfiddle.net/1bb9Lkxb/

关于javascript - Readmore Js 只 chop div 容器而不 chop 文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47214560/

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