当前位置:首页>WordPress插件>7b2主题评论气泡

7b2主题评论气泡

其他主题有接口也可以使用

这个功能来自于https://github.com/515184405/barrage,版权归他所有。

气泡如图:

7b2主题评论气泡

CSS样式代码:

* {
	padding: 0;
	margin: 0;
}

a {
	text-decoration: none;
}

.form-control {
	display: inline-block;
	width: auto;
	padding: 6px 12px;
	font-size: 14px;
	line-height: 1.42857143;
	color: #555;
	background-color: #fff;
	background-image: none;
	border: 1px solid #ccc;
	border-radius: 4px;
	-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
	box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
	-webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
	-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
	transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}

.btn {
	display: inline-block;
	padding: 6px 12px;
	margin-bottom: 0;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.42857143;
	text-align: center;
	white-space: nowrap;
	vertical-align: middle;
	-ms-touch-action: manipulation;
	touch-action: manipulation;
	cursor: pointer;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	background-image: none;
	border: 1px solid transparent;
	border-radius: 4px;
}

.btn-primary {
	color: #fff;
	background-color: #337ab7;
	border-color: #2e6da4;
}

		/*组件主样式*/
.overflow-text {
	display: block;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	opacity: 0;
	clear: both;
	padding: 0 10px;
	border-radius: 10px;
	box-sizing: border-box;
	max-width: 100%;
	color: #fff;
	animation: colorchange 3s infinite alternate;
	-webkit-animation: colorchange 3s infinite alternate;
 /*Safari and Chrome*/
}

@keyframes colorchange {
	0% {
		color: red;
	}

	50% {
		color: green;
	}

	100% {
		color: #6993f9;
	}
}

#Danmu {
	height: 275px;
	overflow: hidden;
	position: fixed;
	z-index: 0;
	max-width: 100%;
	right: 50px;
	bottom: 30px;
}

.overflow-text {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	opacity: 0;
	padding: 3px 10px;
	border-radius: 10px;
	box-sizing: border-box;
	max-width: 100%;
	color: #fff!important;
	animation: colorchange 3s infinite alternate;
	-webkit-animation: colorchange 3s infinite alternate;
}

#Danmu li {
	display: flex;
	opacity: 0;
	border-radius: 20px;
	color: #fff;
	padding: 5px 10px 5px 10px;
	clear: both;
	font-size: 13px;
	height: 30px;
	float: right;
	line-height: 20px;
}

#Danmu li i {
	padding-left: 3px;
	padding-right: 3px;
}

#Danmu .info_zianv {
	text-decoration: underline;
	font-weight: 600;
	color: #fff;
}

#Danmu .info_zianv:hover {
	color: #fff!important;
}

#Danmu li a:first-child {
	margin-right: 6px;
	width: 20px;
}

#Danmu li a:last-child,#Danmu li a:last-child font {
	color: #fff !important;
}

#Danmu li a:last-child n {
	text-decoration: underline;
	margin: 0 5px;
}

#Danmu li img {
	width: 20px;
	height: 20px;
	border-radius: 100%;
	vertical-align: inherit;
	margin-right: 6px;
}

@keyframes colorchange {
	0% {
		color: red;
	}

	50% {
		color: green;
	}

	100% {
		color: #6993f9;
	}
}

@media (max-width: 780px) {
	#Danmu {
		right: 0;
		bottom: 5px;
	}
}

JS代码:

/**
	姓名:冯宇
	site: http://fy.035k.com
	更新时间 :2018-04-03
	QQ : 515184405
	github : https://github.com/515184405/barrage 还有一些其他的项目哦,欢迎star

**/

$.fn.barrage = function(opt) {
	var _self = $(this);
	var opts = { //默认参数
		data: [], //数据列表
		row: 5, //显示行数
		time: 2500, //间隔时间
		gap: 15, //每一个的间隙
		direction: 'bottom right', //方向
		ismoseoverclose: true, //悬浮是否停止
	}
	var settings = $.extend({}, opts, opt); //合并参数
	var M = {},
		Obj = {};
	Obj.data = settings.data.data;
	M.vertical = settings.direction.split(/\s+/)[0]; //纵向
	M.horizontal = settings.direction.split(/\s+/)[1]; //横向
	M.bgColors = ['#f79a3e', '#e66760', '#5382af', ' #aea79f', '#37b8af', '#008b5d', ' #f0b849', '#499df3',
		' #5f6c72', ' #8c88cd'
	]; //随机背景色数组
	Obj.arrEle = []; //预计存储dom集合数组
	M.barrageBox = $('<div id="Danmu""></div>'); //存所有弹幕的盒子
	M.timer = null;
	var createView = function() {
		var randomIndex = Math.floor(Math.random() * M.bgColors.length);
		var ele = $('<li class="overflow-text" style="opacity:0;text-align:' + settings.direction.split(/\s+/)[
				1] + ';float:' + settings.direction.split(/\s+/)[1] + ';background-color:' + M.bgColors[
				randomIndex] + '"; ><a class="img" target="_blank" href="' + (Obj.data[0].user.link ? Obj
				.data[0].user.link : "javascript:;") + '"><img src="' + Obj.data[0].user.avatar +
			'"width="40" height="40"></a>' + Obj.data[0].content + '</li>');
		var str = Obj.data.shift();
		ele.animate({
			'opacity': 1,
			'margin-bottom': settings.gap
		}, 1000)
		M.barrageBox.append(ele);
		Obj.data.push(str);
		if (M.barrageBox.children().length > settings.row) {
			M.barrageBox.children().eq(0).animate({
				'opacity': 0,
			}, 300, function() {
				$(this).css({
					'margin': 0,
				}).remove();
			})
		}
	}
	M.mouseClose = function() {
		settings.ismoseoverclose && (function() {
			M.barrageBox.mouseover(function() {
				clearInterval(M.timer);
				M.timer = null;
			}).mouseout(function() {
				M.timer = setInterval(function() { //循环
					createView();
				}, settings.time)
			})

		})()
	}
	Obj.close = function() {
		M.barrageBox.remove();
		clearInterval(M.timer);
		M.timer = null;
	}
	Obj.start = function() {
		if (M.timer) return;
		_self.append(M.barrageBox); //把弹幕盒子放到页面中
		createView(); //创建试图并开始动画
		M.timer = setInterval(function() { //循环
			createView();
		}, settings.time)
		M.mouseClose();
	}
	return Obj;
}

$.ajax({
	type: "POST",
	data: {

	},
	url: '', //api地址
	success: function(data) {
		var Obj = $('body').barrage({
			data: data,
			//数据
			row: 6,
			//显示行数
			time: 2500,
			//时间
			gap: 15,
			//间隙
			ismoseoverclose: true,
			//悬浮是否停止
		})
		if ($('#Danmu').length == 0) {
			Obj.start();
		}
	}
});

如果主题没有引入jquery.min.js,需要自己引入。

在页脚文件引入css和js:

<link rel="stylesheet" href="/wp-content/themes/css.css">
<script type="text/javascript" src="/wp-content/themes/js.js"></script> 

提供下载的修复了占位置的问题,有弹幕的地方无法点击问题。

    下载权限
    查看
    • 免费下载
      评论并刷新后下载
      登录后下载
    • {{attr.name}}:
    您当前的等级为
    登录后免费下载登录 小黑屋反思中,不准下载! 评论后刷新页面下载评论 支付以后下载 请先登录 您今天的下载次数(次)用完了,请明天再来 支付积分以后下载立即支付 支付以后下载立即支付 您当前的用户组不允许下载升级会员
    您已获得下载权限 您可以每天下载资源次,今日剩余
    一、本站上的部份代码及教程来源于互联网,仅供网友学习交流。如有侵权,无意侵害您的权益,请发送邮件至xutian#ahap.cn或点击右侧 联系我们,我们将尽快处理。
    二、请勿将购买的资源教程转载或分享与他人!

    给TA充电
    共{{data.count}}人
    人已充电
    WordPress小程序WordPress插件默认

    酱茄开源-免费小蓝主题2.6.7-蓝精灵板新增文章流量主!

    2021-12-28 11:48:54

    WordPress美化默认

    网站自定义鼠标右键菜单

    2022-1-4 23:36:11

    62 条回复 A文章作者 M管理员
    1. 手掌心

      66666

    2. 不可爱的昵称

      请问这个如何设置只在首页显示呢

    3. Raymond

      站长,搞定了,谢谢你!

    4. 曾经

      现在7B2主题 没有jquery.min.js 晕死了

      • AHAP

        这个评论气泡还可以吧,我当时做的时候一堆报错的

    5. Legion

      很好的教程就是我太笨了,按照步骤来最后没有任何的提示,努力攒积分?

      • AHAP

        控制台是什么报错呢

      • Legion

        这个位置报错了 $.fn.barrage = function(opt) { 错误提示 Uncaught ReferenceError: $ is not defined

      • AHAP

        引入jquery.min.js

      • Legion

        我是B2的主题,我按照提示写的是在子主题里面加的js和css。麻烦问一下,怎么引入jquery.min.js?我是小白,不知道在哪里写

      • Legion

        感谢站长,完美解决了,实现了气泡,谢谢?

      • AHAP

        ?

      • Legion

        但是还有一点问题,实现了气泡弹窗,但是我F12控制台还是依然报错:child.js?ver=3.3.93:4 Uncaught ReferenceError: $ is not defined

      • AHAP

        引入正确的jquery.min.js

      • Legion

        B2自带的有jquery.min.js吗?路径在哪里

      • AHAP

        b2/Assets

    个人中心
    购物车
    优惠劵
    今日签到
    有新私信 私信列表
    搜索