gpt4 book ai didi

jquery 滚动条 |样式标签与样式属性

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

$(document).ready(function(){
$('.scrollcontainer1').scrollbar();
$('.scrollcontainer2').scrollbar();
})
.scrollcontainer1{
width:200px;
height:200px
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery.scrollbar/0.2.11/jquery.scrollbar.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.scrollbar/0.2.11/jquery.scrollbar.js"></script>
<h1>Width and height in style tag</h1>
<div class="scrollcontainer1 inner-scrollbar">
jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu
jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu
</div>
<h1>Width and height in style attr</h1>
<div class="scrollcontainer2 inner-scrollbar" style="width:200px;height:200px">
jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu
jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu
</div>

这是我的问题。当我在样式属性 div 宽度和高度中使用宽度和高度时,自动设置为内容宽度和高度。但是当我将宽度和高度放在样式标签中时,它就可以工作了。我想用 php 动态改变宽度和高度。所以我想用第二种方法。你能推荐一种方法吗?

最佳答案

这个库似乎覆盖了现有的内联样式:

enter image description here

我认为最安全的做法是使用 Javascript 从 PHP 捕获这些值,并在初始化滚动条后动态更改 div 高度。


编辑:

所以我对如何安全地实现这种能力很感兴趣,并查看了 the docs我注意到他们在内部 div 中设置内联样式并将滚动条应用于包装 div。所以也许这也值得一看。

关于jquery 滚动条 |样式标签与样式属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47982671/

25 4 0