当前位置:首页 > 建站知识 > 正文内容

ZblogPHP网站添加首页滚动公告栏

admin4年前 (2021-09-03)建站知识834

相信下图这种首页滚动公告栏并不陌生吧?为了展示滚动效果,莹莹特意截图了一个滚动到一半的图片。如何为ZblogPHP网站添加这种首页滚动公告栏呢?

ZblogPHP网站添加首页滚动公告栏.jpg

1、为首页调用JS文件添加以下滚动代码:

// 文字滚动
(function($){$.fn.textSlider=function(settings){settings=jQuery.extend({speed:"normal",line:2,timer:1000},settings);return this.each(function(){$.fn.textSlider.scllor($(this),settings)})};$.fn.textSlider.scllor=function($this,settings){var ul=$("ul:eq(0)",$this);var timerID;var li=ul.children();var _btnUp=$(".up:eq(0)",$this);var _btnDown=$(".down:eq(0)",$this);var liHight=$(li[0]).height();var upHeight=0-settings.line*liHight;var scrollUp=function(){_btnUp.unbind("click",scrollUp);ul.animate({marginTop:upHeight},settings.speed,function(){for(i=0;i<settings.line;i++){ul.find("li:first").appendTo(ul)}ul.css({marginTop:0});_btnUp.bind("click",scrollUp)})};var scrollDown=function(){_btnDown.unbind("click",scrollDown);ul.css({marginTop:upHeight});for(i=0;i<settings.line;i++){ul.find("li:last").prependTo(ul)}ul.animate({marginTop:0},settings.speed,function(){_btnDown.bind("click",scrollDown)})};var autoPlay=function(){timerID=window.setInterval(scrollUp,settings.timer)};var autoStop=function(){window.clearInterval(timerID)};ul.hover(autoStop,autoPlay).mouseout();_btnUp.css("cursor","pointer").click(scrollUp);_btnUp.hover(autoStop,autoPlay);_btnDown.css("cursor","pointer").click(scrollDown);_btnDown.hover(autoStop,autoPlay)}})(jQuery);

2、用到的CSS有下面这些:

.breadcrumb {
	margin:5px auto;
	padding-left:10px;
	width:825pt;
	height:30px;
	line-height:30px
}
.bull {
	float:left;
	margin-top:4px;
	width:25px;
	height:23px;
	background:url(../image/bulletin.gif) no-repeat
}
@media screen and (max-width:1100px) {
	#colophon,#content,.breadcrumb,.footer-widget {
	width:100%}
}
.scrolltext {
	overflow:hidden;
	width:70%;
	height:30px;
	line-height:30px
}
.scrolltext ul li {
	overflow:hidden;
	height:30px;
	text-overflow:ellipsis;
	white-space:nowrap;
	word-wrap:normal
}
.scrolltext-title a {
	color:#c01e22
}

3、在需要展示滚动公告栏的位置添加如下调用代码:

<nav class="breadcrumb">	
<div id="scrolldiv">
	<div class="bull"></div>
		<div class="scrolltext">
			<ul style="margin-top: 0px;"><li class="scrolltext-title"><a href="http://www.ynyn34.com/" rel="bookmark" target="_blank">这是zblog滚动公告栏</a></li></ul>
		</div>
</div> 
<script type="text/javascript">$(document).ready(function() {$("#scrolldiv").textSlider({line: 1, speed: 1000, timer: 3000});})</script>
</nav>

每复制一行li标签内容,就会新增一条滚动公告。

扫描二维码推送至手机访问。

版权声明:本文由莹莹笔记发布,如需转载请注明出处。

本文链接:http://www.ynyn34.com/jzzs/27.html

标签: ZblogPHP学习
分享给朋友:

相关文章

zblog调用一定时间内不同分类随机文章的方法

首先在include文件内添加以下功能函数:function xxmy_GetArticleCategorys($Rows,$CategoryID,$hassubcate){     &n...

zblog教程:主页文章列表中插入广告的方法

若您经常浏览wordpress程序的网站,一定看见过网站主页文章列表中显示广告的情况吧?Zblog网站应该通过什么方法实现呢?1、首先您先需要建立一个模板文件,文件的命名随意,我们这里就以post-gg.php为例。2、在主题模板的temp...

宝塔Linux+nginx环境zblog伪静态配置的两种方法

宝塔Linux+nginx环境zblog伪静态配置的两种方法

使用宝塔面板+zblog建站,服务器环境是nginx,想要配置伪静态需要手工修改文件,方法也有很多种,这里记录两种比较简单的。第一种方法:修改conf文件首先在zblog后台静态管理中心自定义规则,提交确认后,生成rewrite规则代码。复...

zblogphp首页不显示指定分类文章的方法

各位站长一定知道,正常情况下,zblog php首页的权重要远大于分类页、标签页、文章页面,因此能够在首页显示的文章也相当于给了充足的展示机会和权重投票。可我们写文章的时候,不一定写过的每一篇文章都希望获得排名和收录,有的时候我们也会写一些...

zblog提取文章中的三张或四张图片作为缩略图的代码

zblog提取文章中的三张或四张图片作为缩略图的代码

zblog提取文章中的三张或四张图片作为缩略图的代码。{php}$pattern="/<img.*?src=[\'|\"](.*?)[\'|\"].*?[\/]?>/i";...

Zblogphp调用相关文章的两种方法

用户在阅读Zblogphp网站文章时,没有哪个站长希望他们看完一篇直接关闭网页离开,而是愿意他们能多看几篇,从而降低网站跳出率,提升用户体验的深度。为了达到这种效果,站长们经常会在文章中插入相关文章推荐,可一篇一篇地添加实在太麻烦。这时我们...