不知道如何将Javascript代码添加到Tumblr
Not sure how to add Javascript code to Tumblr
我从这里得到了代码,这是rossipedia的主要解决方案:固定侧边栏直到div
这是我的 Tumblr 页面和脚本影响的代码部分(main 替换为内容):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
...
<style type="text/css">
#sidebarwrap {
margin: 0 0 1.5em;
width: 16.2em;
float: left;
position: relative;
}
#sidebar {
margin: 0 0 1.5em;
width: 16em;
height: 570px;
position: absolute;
}
#sidebar.fixed {
position: fixed;
top: 0;
}
#footer {
border-top: 4px solid {color:Footer Border};
background: {color:Footer Background};
color: {color:Background};
clear: both;
margin: 0;
overflow: auto;
padding: 0 0.5em;
}
#content {
margin-bottom: 4.5em;
margin-left: 18.5em;
min-width: 500px;
min-height: 550px;
}
</style>
</head>
身体
<body>
<div id="contain">
<div id="sidebarwrap">
<div id="sidebar">
...Stuff...
</div>
</div>
<div id="content">
...Stuff...
</div>
</div>
<div id="footer">
<div id="footer-container">
...Stuff...
</div>
</div>
然后,我将脚本包含在/body 之前,如下所示:
<script type="text/javascript">
...Script...
</script>
我一直在检查拼写并确保一切正常,但这一切都不起作用。至少不是那个JS。我使用的其他JS工作得很好...该脚本应该让我的侧边栏与用户一起滚动,然后在重叠页脚之前停止。然而,脚本的行为就像它甚至不存在一样,侧边栏没有移动一英寸......哎呀,我什至在其小提琴页面上篡改了原始版本,使其与我的页面具有相同的布局和顺序,并且它仍然运行良好。
我错过了什么吗?每个人都在谈论 JQuery,我不完全确定那是什么,或者我是否应该使用它......如果有人能帮助我看到我做错了什么,我将不胜感激!:会
看起来你确实需要在页面上加载jQuery才能使用你添加的代码。 jQuery是一个JavaScript库;它提供了"$"函数。
要在页面中加载 jQuery,请在固定侧边栏代码之前添加以下内容:
<!-- Note that we have a closing tag right after the opening tag here. -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
// Your code here
</script>
相关文章:
- 正在添加'X'按钮,在文本字段旁边使用javascript
- 如何在映射数组中添加换行符
- 正在将数据主题添加到所有项目
- ZeroClipboard-在复制之前添加到值
- 我可以在json对象中添加一个函数吗
- 将输入字段中的文本提交到我的数据库,同时将其添加到我的列表中
- 正在SharePoint 2013母版页中添加JQuery移动文件
- 如何添加浮动和非浮动,其他
- 添加文字和评论功能更新Div
- 如果使用 lodash 将属性存在于另一个对象中,则向对象添加属性
- 动态地改变“”的URL;添加新项目”;链接使用javascript/jquery
- 在函数中添加数组元素的数值
- 如何将歌曲添加到jPlayer
- 在html Select中添加搜索
- Java脚本时间添加
- FabricJs-限制主对象内添加对象的移动区域
- 添加JS时Tumblr的奇怪行为
- 不知道如何将Javascript代码添加到Tumblr
- 为Tumblr上的HTML标签添加事件监听器
- 我如何将JavaScript添加到我的Tumblr博客上的每个非索引页面