Skip to content

页脚

页脚渐变色滚动动画

CSS
css
/* 页脚footer */
/* 渐变色滚动动画 */
@-webkit-keyframes Gradient {
  0% {
      background-position: 0 50%;
  }

  50% {
      background-position: 100% 50%;
  }

  100% {
      background-position: 0 50%;
  }
}

@-moz-keyframes Gradient {
  0% {
      background-position: 0 50%;
  }

  50% {
      background-position: 100% 50%;
  }

  100% {
      background-position: 0 50%;
  }
}

@keyframes Gradient {
  0% {
      background-position: 0 50%;
  }

  50% {
      background-position: 100% 50%;
  }

  100% {
      background-position: 0 50%;
  }
}
#footer {
  background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
  background-size: 400% 400%;
  -webkit-animation: Gradient 10s ease infinite;
  -moz-animation: Gradient 10s ease infinite;
  animation: Gradient 10s ease infinite;
  -o-user-select: none;
  -ms-user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}
#footer:before {
  background-color: rgba(0, 0, 0, 0);
}

页脚跳动的心

  1. 修改themes\butterfly\layout\includes\footer.pug文件,加个爱心图标
diff
- .copyright!= `©${nowYear} by ${config.author}`
+ .copyright!= `&copy;${nowYear} <i id="heartbeat" style="color:#FF6A6A" class="fa fa-heartbeat"></i> ${config.author}`
  1. 挂载 CSS,使其动起来,如果用了上面的动态图标可以跳过这一步
CSS
css
/* 跳动的心 */
#heartbeat {
  color: red;
  animation: iconAnimate 1.33s ease-in-out infinite;
}
@-moz-keyframes iconAnimate {
  0%,
  100% {
    transform: scale(1);
  }
  10%,
  30% {
    transform: scale(0.9);
  }
  20%,
  40%,
  60%,
  80% {
    transform: scale(1.1);
  }
  50%,
  70% {
    transform: scale(1.1);
  }
}
@-webkit-keyframes iconAnimate {
  0%,
  100% {
    transform: scale(1);
  }
  10%,
  30% {
    transform: scale(0.9);
  }
  20%,
  40%,
  60%,
  80% {
    transform: scale(1.1);
  }
  50%,
  70% {
    transform: scale(1.1);
  }
}
@-o-keyframes iconAnimate {
  0%,
  100% {
    transform: scale(1);
  }
  10%,
  30% {
    transform: scale(0.9);
  }
  20%,
  40%,
  60%,
  80% {
    transform: scale(1.1);
  }
  50%,
  70% {
    transform: scale(1.1);
  }
}
@keyframes iconAnimate {
  0%,
  100% {
    transform: scale(1);
  }
  10%,
  30% {
    transform: scale(0.9);
  }
  20%,
  40%,
  60%,
  80% {
    transform: scale(1.1);
  }
  50%,
  70% {
    transform: scale(1.1);
  }
}

页脚养鱼

  1. 引入jquery
yml
inject:
  head:
  bottom:
    - <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    - <script src="/js/fish.js" data-pjax></script>
  1. 引入fish.js,如果开启了pjax需要添加data-pjax属性
js
fish();
function fish() {
  return (
    $("footer").append(
      '<div class="fish_container" id="jsi-flying-fish-container"></div>'
    ),
    $(".fish_container").css({
      "z-index": -1,
      width: "100%",
      height: "160px",
      margin: 0,
      padding: 0,
    }),
    $("#footer-wrap").css({
      position: "absolute",
      "text-align": "center",
      top: 0,
      right: 0,
      left: 0,
      bottom: 0,
    }),
    this
  );
}
var RENDERER = {
	POINT_INTERVAL : 5,
	FISH_COUNT : 3,
	MAX_INTERVAL_COUNT : 50,
	INIT_HEIGHT_RATE : 0.5,
	THRESHOLD : 50,
	
	init : function(){
		this.setParameters();
		this.reconstructMethods();
		this.setup();
		this.bindEvent();
		this.render();
	},
	setParameters : function(){
		this.$window = $(window);
		this.$container = $('#jsi-flying-fish-container');
		this.$canvas = $('<canvas />');
		this.context = this.$canvas.appendTo(this.$container).get(0).getContext('2d');
		this.points = [];
		this.fishes = [];
		this.watchIds = [];
	},
	createSurfacePoints : function(){
		var count = Math.round(this.width / this.POINT_INTERVAL);
		this.pointInterval = this.width / (count - 1);
		this.points.push(new SURFACE_POINT(this, 0));
		
		for(var i = 1; i < count; i++){
			var point = new SURFACE_POINT(this, i * this.pointInterval),
				previous = this.points[i - 1];
				
			point.setPreviousPoint(previous);
			previous.setNextPoint(point);
			this.points.push(point);
		}
	},
	reconstructMethods : function(){
		this.watchWindowSize = this.watchWindowSize.bind(this);
		this.jdugeToStopResize = this.jdugeToStopResize.bind(this);
		this.startEpicenter = this.startEpicenter.bind(this);
		this.moveEpicenter = this.moveEpicenter.bind(this);
		this.reverseVertical = this.reverseVertical.bind(this);
		this.render = this.render.bind(this);
	},
	setup : function(){
		this.points.length = 0;
		this.fishes.length = 0;
		this.watchIds.length = 0;
		this.intervalCount = this.MAX_INTERVAL_COUNT;
		this.width = this.$container.width();
		this.height = this.$container.height();
		this.fishCount = this.FISH_COUNT * this.width / 500 * this.height / 500;
		this.$canvas.attr({width : this.width, height : this.height});
		this.reverse = false;
		
		this.fishes.push(new FISH(this));
		this.createSurfacePoints();
	},
	watchWindowSize : function(){
		this.clearTimer();
		this.tmpWidth = this.$window.width();
		this.tmpHeight = this.$window.height();
		this.watchIds.push(setTimeout(this.jdugeToStopResize, this.WATCH_INTERVAL));
	},
	clearTimer : function(){
		while(this.watchIds.length > 0){
			clearTimeout(this.watchIds.pop());
		}
	},
	jdugeToStopResize : function(){
		var width = this.$window.width(),
			height = this.$window.height(),
			stopped = (width == this.tmpWidth && height == this.tmpHeight);
			
		this.tmpWidth = width;
		this.tmpHeight = height;
		
		if(stopped){
			this.setup();
		}
	},
	bindEvent : function(){
		this.$window.on('resize', this.watchWindowSize);
		this.$container.on('mouseenter', this.startEpicenter);
		this.$container.on('mousemove', this.moveEpicenter);
		this.$container.on('click', this.reverseVertical);
	},
	getAxis : function(event){
		var offset = this.$container.offset();
		
		return {
			x : event.clientX - offset.left + this.$window.scrollLeft(),
			y : event.clientY - offset.top + this.$window.scrollTop()
		};
	},
	startEpicenter : function(event){
		this.axis = this.getAxis(event);
	},
	moveEpicenter : function(event){
		var axis = this.getAxis(event);
		
		if(!this.axis){
			this.axis = axis;
		}
		this.generateEpicenter(axis.x, axis.y, axis.y - this.axis.y);
		this.axis = axis;
	},
	generateEpicenter : function(x, y, velocity){
		if(y < this.height / 2 - this.THRESHOLD || y > this.height / 2 + this.THRESHOLD){
			return;
		}
		var index = Math.round(x / this.pointInterval);
		
		if(index < 0 || index >= this.points.length){
			return;
		}
		this.points[index].interfere(y, velocity);
	},
	reverseVertical : function(){
		this.reverse = !this.reverse;
		
		for(var i = 0, count = this.fishes.length; i < count; i++){
			this.fishes[i].reverseVertical();
		}
	},
	controlStatus : function(){
		for(var i = 0, count = this.points.length; i < count; i++){
			this.points[i].updateSelf();
		}
		for(var i = 0, count = this.points.length; i < count; i++){
			this.points[i].updateNeighbors();
		}
		if(this.fishes.length < this.fishCount){
			if(--this.intervalCount == 0){
				this.intervalCount = this.MAX_INTERVAL_COUNT;
				this.fishes.push(new FISH(this));
			}
		}
	},
	render : function(){
		requestAnimationFrame(this.render);
		this.controlStatus();
		this.context.clearRect(0, 0, this.width, this.height);
		this.context.fillStyle = 'hsl(0, 0%, 95%)';
		
		for(var i = 0, count = this.fishes.length; i < count; i++){
			this.fishes[i].render(this.context);
		}
		this.context.save();
		this.context.globalCompositeOperation = 'xor';
		this.context.beginPath();
		this.context.moveTo(0, this.reverse ? 0 : this.height);
		
		for(var i = 0, count = this.points.length; i < count; i++){
			this.points[i].render(this.context);
		}
		this.context.lineTo(this.width, this.reverse ? 0 : this.height);
		this.context.closePath();
		this.context.fill();
		this.context.restore();
	}
};
var SURFACE_POINT = function(renderer, x){
	this.renderer = renderer;
	this.x = x;
	this.init();
};
SURFACE_POINT.prototype = {
	SPRING_CONSTANT : 0.03,
	SPRING_FRICTION : 0.9,
	WAVE_SPREAD : 0.3,
	ACCELARATION_RATE : 0.01,
	
	init : function(){
		this.initHeight = this.renderer.height * this.renderer.INIT_HEIGHT_RATE;
		this.height = this.initHeight;
		this.fy = 0;
		this.force = {previous : 0, next : 0};
	},
	setPreviousPoint : function(previous){
		this.previous = previous;
	},
	setNextPoint : function(next){
		this.next = next;
	},
	interfere : function(y, velocity){
		this.fy = this.renderer.height * this.ACCELARATION_RATE * ((this.renderer.height - this.height - y) >= 0 ? -1 : 1) * Math.abs(velocity);
	},
	updateSelf : function(){
		this.fy += this.SPRING_CONSTANT * (this.initHeight - this.height);
		this.fy *= this.SPRING_FRICTION;
		this.height += this.fy;
	},
	updateNeighbors : function(){
		if(this.previous){
			this.force.previous = this.WAVE_SPREAD * (this.height - this.previous.height);
		}
		if(this.next){
			this.force.next = this.WAVE_SPREAD * (this.height - this.next.height);
		}
	},
	render : function(context){
		if(this.previous){
			this.previous.height += this.force.previous;
			this.previous.fy += this.force.previous;
		}
		if(this.next){
			this.next.height += this.force.next;
			this.next.fy += this.force.next;
		}
		context.lineTo(this.x, this.renderer.height - this.height);
	}
};
var FISH = function(renderer){
	this.renderer = renderer;
	this.init();
};
FISH.prototype = {
	GRAVITY : 0.4,
	
	init : function(){
		this.direction = Math.random() < 0.5;
		this.x = this.direction ? (this.renderer.width + this.renderer.THRESHOLD) : -this.renderer.THRESHOLD;
		this.previousY = this.y;
		this.vx = this.getRandomValue(4, 10) * (this.direction ? -1 : 1);
		
		if(this.renderer.reverse){
			this.y = this.getRandomValue(this.renderer.height * 1 / 10, this.renderer.height * 4 / 10);
			this.vy = this.getRandomValue(2, 5);
			this.ay = this.getRandomValue(0.05, 0.2);
		}else{
			this.y = this.getRandomValue(this.renderer.height * 6 / 10, this.renderer.height * 9 / 10);
			this.vy = this.getRandomValue(-5, -2);
			this.ay = this.getRandomValue(-0.2, -0.05);
		}
		this.isOut = false;
		this.theta = 0;
		this.phi = 0;
	},
	getRandomValue : function(min, max){
		return min + (max - min) * Math.random();
	},
	reverseVertical : function(){
		this.isOut = !this.isOut;
		this.ay *= -1;
	},
	controlStatus : function(context){
		this.previousY = this.y;
		this.x += this.vx;
		this.y += this.vy;
		this.vy += this.ay;
		
		if(this.renderer.reverse){
			if(this.y > this.renderer.height * this.renderer.INIT_HEIGHT_RATE){
				this.vy -= this.GRAVITY;
				this.isOut = true;
			}else{
				if(this.isOut){
					this.ay = this.getRandomValue(0.05, 0.2);
				}
				this.isOut = false;
			}
		}else{
			if(this.y < this.renderer.height * this.renderer.INIT_HEIGHT_RATE){
				this.vy += this.GRAVITY;
				this.isOut = true;
			}else{
				if(this.isOut){
					this.ay = this.getRandomValue(-0.2, -0.05);
				}
				this.isOut = false;
			}
		}
		if(!this.isOut){
			this.theta += Math.PI / 20;
			this.theta %= Math.PI * 2;
			this.phi += Math.PI / 30;
			this.phi %= Math.PI * 2;
		}
		this.renderer.generateEpicenter(this.x + (this.direction ? -1 : 1) * this.renderer.THRESHOLD, this.y, this.y - this.previousY);
		
		if(this.vx > 0 && this.x > this.renderer.width + this.renderer.THRESHOLD || this.vx < 0 && this.x < -this.renderer.THRESHOLD){
			this.init();
		}
	},
	render : function(context){
		context.save();
		context.translate(this.x, this.y);
		context.rotate(Math.PI + Math.atan2(this.vy, this.vx));
		context.scale(1, this.direction ? 1 : -1);
		context.beginPath();
		context.moveTo(-30, 0);
		context.bezierCurveTo(-20, 15, 15, 10, 40, 0);
		context.bezierCurveTo(15, -10, -20, -15, -30, 0);
		context.fill();
		
		context.save();
		context.translate(40, 0);
		context.scale(0.9 + 0.2 * Math.sin(this.theta), 1);
		context.beginPath();
		context.moveTo(0, 0);
		context.quadraticCurveTo(5, 10, 20, 8);
		context.quadraticCurveTo(12, 5, 10, 0);
		context.quadraticCurveTo(12, -5, 20, -8);
		context.quadraticCurveTo(5, -10, 0, 0);
		context.fill();
		context.restore();
		
		context.save();
		context.translate(-3, 0);
		context.rotate((Math.PI / 3 + Math.PI / 10 * Math.sin(this.phi)) * (this.renderer.reverse ? -1 : 1));
		
		context.beginPath();
		
		if(this.renderer.reverse){
			context.moveTo(5, 0);
			context.bezierCurveTo(10, 10, 10, 30, 0, 40);
			context.bezierCurveTo(-12, 25, -8, 10, 0, 0);
		}else{
			context.moveTo(-5, 0);
			context.bezierCurveTo(-10, -10, -10, -30, 0, -40);
			context.bezierCurveTo(12, -25, 8, -10, 0, 0);
		}
		context.closePath();
		context.fill();
		context.restore();
		context.restore();
		this.controlStatus(context);
	}
};
$(function(){
	RENDERER.init();
});
  1. css调整
css
#footer-wrap {
    /* 页脚文字高度调整,防遮挡 */
    padding: 20px 20px;
}
#footer {
    background-color: var(--xdog-background-color);
}

快捷导航

未测试代码

修改\theme\butterfly\layout\includes\footer.pug

pug
pug
#footer_icon
  .icon_left
    a.icon_link(href="https://github.com/Lea321" title="我的Github主页")
      i.fa-brands.fa-github.fa-fw
      
    a.icon_link(href="/star" title="收藏夹")
      i.fa-solid.fa-star.fa-fw

  img.footer_logo(src='https://pblood.oss-cn-hongkong.aliyuncs.com/img/site/logo.png' onclick="btf.scrollToDest(0,500)" title="返回顶部")

  .icon_left
    a.icon_link(href="/" title="我的主页")
      i.fa-solid.fa-compass.fa-fw

    a.icon_link(href="https://res.abeim.cn/api/qq/?qq=12345" title="联系QQ")
      i.fa-brands.fa-qq.fa-fw

    a.icon_link(href="/wechat/" title="联系微信")
      i.fa-brands.fa-weixin.fa-fw
    
    a.icon_link(href="mailto:12345@qq.com" title="联系邮箱")
      i.fa-solid.fa-envelope.fa-fw

#leonus-footer
  .footer-group
    h3.footer-title 直达
    .footer-links
      a.footer-item(href="/") 我的主页
      a.footer-item(href="/talk") 空间说说
      a.footer-item(href="/wallpaper") 壁纸收藏
      a.footer-item(href="/bg") 切换背景
  .footer-group
    h3.footer-title 分类
    .footer-links
      a.footer-item(href="/categories/博客相关") 博客相关
      a.footer-item(href="/categories/学习笔记") 学习笔记
      a.footer-item(href="/categories/实用教程") 实用教程
      a.footer-item(href="/categories/生活记录") 生活记录
      a.footer-item(href="/categories/随便写写") 随便写写
  .footer-group
    h3.footer-title 关于
    .footer-links
      a.footer-item(href="/about/#关于我") 关于我
      a.footer-item(href="/about/#访问统计") 站点统计
      a.footer-item(href="/archives") 文章归档
      a.footer-item(href="/update") 更新记录
  .footer-group#friend-links-in-footer
    h3.footer-title 友链
    .footer-links
      a.footer-item(href="xxx") xxx
      a.footer-item(href="xxx") xxx
      a.footer-item(href="/link") 查看更多
#footer-bottom
  .footer-bottom-links
    .footer-bottom-left
      #runtime
    .footer-bottom-right
      a.footer-bottom-link(href="https://hexo.io/zh-cn/" title="框架") Hexo
      a.footer-bottom-link |
      a.footer-bottom-link(href="https://butterfly.js.org/" title="主题") Butterfly
      a.footer-bottom-link |
      a.footer-bottom-link(href="https://beian.miit.gov.cn/" title="备案号") 豫ICP备xxx号
CSS
css
#footer {
  background: linear-gradient(180deg,var(--heo-background) 0,var(--heo-card-bg) 25%);
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  z-index: 101;
}

div#footer_icon {
  justify-content: center;
  display: flex;
  padding-top: 2rem;
  align-items: center;
}

#footer_icon i {
  padding-top: 1px;
  font-size: 20px;
  color: #fff;
  transition: .3s;
}

#footer_icon, #leonus-footer {
  margin: auto;
  max-width: 1200px;
  width: 97%;
}

.icon_left, .icon_right {
  display: flex;
}

a.icon_link {
  height: 40px;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1rem;
  background-color: var(--font-color);
  border-radius: 3rem;
}

img.footer_logo {
  border-radius: 50%;
  width: 60px;
  height: 60px;
  margin: 0 1rem;
  cursor: pointer;
  filter: drop-shadow(0 0 12px rgba(187, 138, 64, .35));
  transition: cubic-bezier(0, 0, 0, 1.29) .5s;
  transition: all .25s;
}

#leonus-footer {
  border-radius: 0 0 15px 15px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 3rem;
  padding: 0 2rem 2rem;
}

#leonus-footer .footer-group {
  min-width: 120px;
}

#leonus-footer .footer-links {
  display: flex;
  flex-direction: column;
}

#leonus-footer .footer-item {
  font-size: 1rem;
  line-height: 1;
  margin: .38rem 0;
  color: var(--font-color);
}

#footer-bottom {
  font-size: 1rem;
  padding: 1rem;
  color: var(--font-color);
  margin-top: 1rem;
  background: var(--card-bg);
  display: flex!important;
  overflow: hidden;
  z-index: 1002;
  transition: .3s;
  border-top: 1px solid #e3e8f7;
}


#footer-bottom .footer-bottom-left {
  display: flex;
  flex-wrap: wrap;
  min-height: 32px;
  color: var(--font-color);
  font-weight: 700;
  white-space: nowrap;
}

#footer-bottom .footer-bottom-right {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}

#footer-bottom .footer-bottom-links {
  display: flex;
  justify-content: space-between;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  flex-wrap: wrap;
}

#footer-bottom .footer-bottom-link {
  margin-right: 1rem;
  color: var(--font-color);
  font-weight: 700;
  white-space: nowrap;
}