能不能把博客背景替换为 js 插件

2015-07-25 11:13:28 +08:00
 lksltjw

比如说我现在用的是ghost博客
我想吧背景换为particleground的动态的js而不是静态的图片
网址https://github.com/jnicol/particleground
这个。。可不可行?

其实我对前端一窍不通

2081 次点击
所在节点    前端开发
4 条回复
loading
2015-07-25 11:18:39 +08:00
$('body').particleground();
alay9999
2015-07-25 11:25:07 +08:00
在页尾 </body> 之前添加如下代码,其中第二行的文件地址要自己修改一下,具体是下载 https://github.com/jnicol/particleground 其中的 jquery.particleground.min.js 文件,放在你的网站里,然后换做这个文件的地址

<script type="text/javascript" src="http://upcdn.b0.upaiyun.com/libs/jquery/jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="js/jquery.particleground.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('body').particleground();
});
</script>
lksltjw
2015-07-25 15:43:53 +08:00
@loading
@alay9999
感谢!
回头试一试。。
lksltjw
2015-07-25 15:51:51 +08:00
@alay9999
比如说casper该怎么改呢?
blog.cover是自己设置的图片背景


#这是index.hbs
<header class="main-header {{#if @blog.cover}}" style="background-image: url({{@blog.cover}}){{else}}no-cover{{/if}}">
<nav class="main-nav overlay clearfix">
{{#if @blog.logo}}<a class="blog-logo" href="{{@blog.url}}"><img src="{{@blog.logo}}" alt="{{@blog.title}}" /></a>{{/if}}
{{#if @blog.navigation}}
<a class="menu-button icon-menu" href="#"><span class="word">Menu</span></a>
{{/if}}
</nav>
<div class="vertical">
<div class="main-header-content inner">
<h1 class="page-title">{{@blog.title}}</h1>
<h2 class="page-description">{{@blog.description}}</h2>
</div>
</div>
<a class="scroll-down icon-arrow-left" href="#content" data-offset="-45"><span class="hidden">Scroll Down</span></a>
</header>

{{! The main content area on the homepage }}
<main id="content" class="content" role="main">

{{! The tag below includes the post loop - partials/loop.hbs }}
{{> "loop"}}

</main>

#然后这是default.hbs
<!DOCTYPE html>
<html>
<head>
{{! Document Settings }}
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

{{! Page Meta }}
<title>{{meta_title}}</title>
<meta name="description" content="{{meta_description}}" />

<meta name="HandheldFriendly" content="True" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<link rel="shortcut icon" href="{{asset "favicon.ico"}}">

{{! Styles'n'Scripts }}
<link rel="stylesheet" type="text/css" href="{{asset "css/screen.css"}}" />
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Merriweather:300,700,700italic,300italic|Open+Sans:700,400" />

{{! Ghost outputs important style and meta data with this tag }}
{{ghost_head}}
</head>
<body class="{{body_class}} nav-closed">

{{navigation}}

<div class="site-wrapper">

{{! Everything else gets inserted here }}
{{{body}}}

<footer class="site-footer clearfix">
<section class="copyright"><a href="{{@blog.url}}">{{@blog.title}}</a> &copy; {{date format="YYYY"}}</section>
<section class="poweredby">Proudly published with <a href="https://ghost.org">Ghost</a></section>
</footer>

</div>

{{! Ghost outputs important scripts and data with this tag }}
{{ghost_foot}}

{{! The main JavaScript file for Casper }}
<script type="text/javascript" src="{{asset "js/jquery.fitvids.js"}}"></script>
<script type="text/javascript" src="{{asset "js/index.js"}}"></script>

</body>
</html>

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/208225

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX