- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在构建一个股票代码,我正在尝试使用 Smooth Div Scroll插件,但我无法让它与动态创建的段落标签一起使用。它不是创建滚动的水平列表,而是将 P 标签垂直转储到页面上。如果段落标签是静态添加的,它们会正确定位和滚动。当我在 Firebug 中比较静态版本和这个动态版本时,html 看起来一样,所以我猜这是一个 CSS 问题,但我没有任何运气。
编辑:这是一个jsFiddle
有什么建议吗?谢谢
这是代码
$(window).load(function () {
var $divScrollableArea = $(".scrollableArea");
var $stocks = new Array("GOLD", "SSRI", "PTM", "PAL", "USD", "SH", "DJI");
$.each($stocks, function (index, item) {
var url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22" + item + "%22)%0A%09%09&&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
$(function () {
var jqxhr = $.getJSON(url, function (json) {
$divScrollableArea.append("<p>" + item + "<br /><span class='left'>" + json.query.results.quote.BidRealtime +
"</span><span class='right'>" + json.query.results.quote.Change_PercentChange + "</span></p>");
})
.success(function () { BuildScroll(); });
});
});
function BuildScroll() {
$("div#scrollingText").smoothDivScroll({
autoScroll: "always",
autoScrollDirection: "endlessloopright",
autoScrollStep: 1,
autoScrollInterval: 15
});
}
});
<style type="text/css">
.stock
{
font: bold .8em Verdana;
padding: 5px;
width: 100%;
}
.innerStock
{
float: left;
margin-right: 20px;
}
.left
{
font: normal .7em Verdana;
text-align: left;
width: 30%;
padding-right: 15px;
}
.right
{
font: normal .7em Verdana;
text-align: right;
color: red;
}
#scrollingText
{
width: 100px;
height: 35px;
border: solid 1px #ccc;
position: relative;
padding: 2px 0px;
}
#scrollingText div.scrollableArea p
{
display: block;
float: left;
margin: 0;
padding-right: 7px;
padding-top: 1px;
font-family: Courier, Arial, Sans-Serif;
font-size: 12px;
line-height: 12px;
font-weight: normal;
background-color: #fff;
color: #000;
white-space: nowrap;
width:300px;
}
</style>
<div id="scrollingText">
<div class="scrollWrapper">
<div class="scrollableArea">
</div>
</div>
</div>
最佳答案
你是对的,这是一个 CSS 问题。
更具体地说,是 #scrollingText
的宽度 (100px) 导致了换行。如果您删除此属性,您的段落将 float (减少段落的宽度也是有好处的)。
如果你想保持 #scrollingText
的大小固定,你需要为 div.scrollWrapper
定义样式,如下所示:
div.scrollWrapper {
display: block;
width: 800px;
}
只需确保宽度大于所包含段落的所有宽度之和即可。我已经更新了你的 fiddle (不是我也调整了段落的宽度):http://jsfiddle.net/RZBUJ/2/
关于jQuery smooth div 滚动不滚动动态创建的段落标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7719570/
我有几个数据点似乎适合于通过它们拟合样条曲线。当我这样做时,我得到了一个非常坎bump的拟合,例如过度拟合,这不是我所理解的平滑。 是否有特殊的选项/参数来恢复像here这样的非常平滑的样条曲线的功能
编辑:我找到了一个 jQuery 解决方案! https://codepen.io/chriscoyier/pen/dpBMVP这个确实适用于 iOS。我想 jQuery 桥接浏览器支持问题的日子还没
我正在阅读世界各国的一些数据,并正在使用 Google 的可视化小工具,尤其是 map visualizations 。问题是,美国总是走在前面。虽然大多数国家/地区的值在 1 到 50 之间,但美国
我在我的 friend Google 上搜索了一些代码来进行平滑滚动并找到了这个:Smooth vertical scrolling on mouse wheel in vanilla javascr
在过去的一个半星期里,我一直在使用 Java 和 Swing 从头开始编写游戏。到目前为止,游戏运行一切顺利,除了一件事:跳跃。我正在尝试实现抛物线跳跃,以便玩家不只是向上传送一点点。相反,我希望
我将数据从 Cursor 加载到 ListView ,但我的 ListView 并没有真正显示“平滑”。当我在 ListView 的 scollbar 上上下拖动时,数据会发生变化。有些项目在我的列表
谁能给我一些关于如何生成“平滑”随机数的提示?这就是我所说的平滑: 随机数应在游戏中使用,例如风向和强度(有没有人记得好老的“蠕虫”?)。当然,每隔一秒左右为这些值设置随机数看起来会非常不稳定。我宁愿
这是我第一次在这里写文章。我对 JQuery 动画有一些问题:当持续时间非常慢(例如 10000)时, Action 不够平滑。我的 div 需要一个“自然”的运动。有人知道我的问题的解决方案吗?或者
我有一个数组: array = [10, 10, 10, 10, 10] 我想遍历这个数组,以便它得到一个基于整数的“斜率”。所以如果整数是 2,结果将是: array = [0, 5, 10, 5,
我正在构建一个股票代码,我正在尝试使用 Smooth Div Scroll插件,但我无法让它与动态创建的段落标签一起使用。它不是创建滚动的水平列表,而是将 P 标签垂直转储到页面上。如果段落标签是静态
有没有办法在平滑滚动(参见示例)结束时获得回调? 我唯一能想到的就是观察 scroll 的缺失事件,但没有办法将它们与 anchor 点击联系起来 - 您如何将它们与只是自己滚动页面的用户区分开来?
问题背景: 我正在 ASP.NET MVC 项目中使用 Twitter Bootstrap 3 开发一个单页网站。 问题: 我目前正在尝试实现“平滑滚动”,该滚动应该通过从导航栏下拉列表中单击来滚动到
平滑滚动对我来说一直感觉非常缓慢和滞后(我希望一切都快快),但幸运的是可以在浏览器设置中禁用它。但是,我注意到越来越多的网页使用 javascript 强制平滑滚动,无论我的设置如何(例如 this
我有一个由 div 制成的小 table ,上面有一个“添加新”按钮来添加新行,每行上有一个 x 按钮来删除该行。表格有一个最大高度,一旦达到这个高度就会在添加新行时滚动到底部。我已经在 css 中将
我使用了 CSS TRICKS 的 Smooth Scroll Plugin,它工作得很好,但只有 2 个 ancoher 链接,而不是另一个链接,请在此处查看演示, LIVE DEMO 它对行业和定
我尝试为 Google 地球 (c++) 编写自己的应用程序界面。我正在使用 Earthlib 来控制相机 (EARTHLib::ICameraInfoGE)。该接口(interface)允许控制相机
如果我想编写一个函数(可能也是一个类),它从不可变的查找表(调用构造函数时固定)返回线性“平滑”数据,如下所示: 例如func(5.0) == 0.5。 存储查找表的最佳方式是什么? 我正在考虑使用两
根据 Chromecast 开发人员页面,Chromecast 支持 SmoothStreaming 容器,我相信它使用带有 .ismv 扩展名的视频块。我在播放这些视频文件时遇到问题。 如果我没记错
原始问题 我想平滑我的解释变量,例如车辆的“速度”数据,然后使用此平滑后的值。我搜索了很多东西,却没有发现直接答案。 我知道如何计算内核密度估计(density()或KernSmooth::bkde(
我尝试了几种不同的开箱即用选项来平滑我的数据中的一个步骤,但还没有完全找到我所追求的。在下面粘贴一个小的可复制示例。正如下面的屏幕截图中突出显示的,是否有一个 R 函数可以平滑步骤,类似于 smoot
我是一名优秀的程序员,十分优秀!