Skip to content

Instantly share code, notes, and snippets.

View ifeiwu's full-sized avatar

pagepan ifeiwu

View GitHub Profile
@ifeiwu
ifeiwu / multi-text-swipe-up-to-switch.html
Created August 22, 2021 03:04
多文字向上滑动切换
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>多文字向上滑动切换</title>
<link rel="stylesheet" href="../reset.css" />
<style>
.textbox {
@ifeiwu
ifeiwu / jquery-iframe-auto-height.js
Last active June 27, 2021 03:15
jQuery自动调整iframe页面高度
$(function() {
var height, _height;
setInterval(function(){
height = $(document.body).height();
if (height != _height){
_height = height;
$(parent.document.body).find("#testifr").height(height);
}
}, 0);
});
@ifeiwu
ifeiwu / color-to-hex.js
Last active June 27, 2021 03:15
颜色RGB转HEX
String.prototype.colorHex = function() {
var that = this;
//十六进制颜色值的正则表达式
var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
// 如果是rgb颜色表示
if (/^(rgb|RGB)/.test(that)) {
var aColor = that.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
var strHex = "#";
for (var i=0; i<aColor.length; i++) {
@ifeiwu
ifeiwu / lighten-darken-color.js
Last active June 27, 2021 03:14
颜色明暗度调整
var LightenDarkenColor = function(col, amt) {
var usePound = false;
if (col[0] == "#") {
col = col.slice(1);
usePound = true;
}
var num = parseInt(col,16);
@ifeiwu
ifeiwu / css3-elements-vertically-centered.md
Last active November 19, 2018 08:59
CSS3元素垂直居中

HTML

<div class="vertical-container">
  <div class="vertical-center">Centered</div>
</div>

CSS

.vertical-container {
@ifeiwu
ifeiwu / image-zoom-with-mouse-movements.js
Last active June 27, 2021 03:14
图片放大跟随鼠标移动
$(document.body).append('<div id="zoom" style="background-image:'+$(this).css('background-image')+'"></div>');
var $offset = $slidea.offset();
$('#zoom').css({'width':$slidea.width(),'height':$slidea.height(),'left':$offset.left,'top':$offset.top});
$('#zoom').animate({left:0,top:0,bottom:0,right:0,height:'100%',width:'100%'}, 500, function() {
var $source = $('#zoom'),
offset = $source.offset(),