Mik*_*ord 4 html javascript css jquery marquee
好继承我的问题.假设我有3个div标签,都是100像素宽:
<--- DIV WIDTH --->
Text in div 1
Text in div two, it overflows
Text in div three
<--- DIV WIDTH --->
Run Code Online (Sandbox Code Playgroud)
现在,我目前有这个div的css:
width:100px;
overflow:hidden;
Run Code Online (Sandbox Code Playgroud)
我想要做的是如果文本溢出,它会像一个选框一样滚动,所以如果你等一下,所有的文字都可以看到.但我只希望字幕显示文本是否溢出.
我该怎么办?
谢谢,托尼
解决条件部分
var el = $('your element');
if (el.get(0).scrollWidth > el.width()) {
// Your marquee code here
}
Run Code Online (Sandbox Code Playgroud)
$(function(){
$box = $('div.box');
$box.children().each(function(){
if ($box.width() < $(this).width()) {
$(this).wrap('<marquee>');
}
)};
});
Run Code Online (Sandbox Code Playgroud)
可以在 jQuery 中工作(我还没有检查过。如果您有任何问题请回复)。或者,您可以在 css 中设置滚动属性。
归档时间: |
|
查看次数: |
8334 次 |
最近记录: |