Skip to content

Instantly share code, notes, and snippets.

Avatar

pagepan ifeiwu

View GitHub Profile
View css3-elements-vertically-centered.md

HTML

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

CSS

.vertical-container {
@ifeiwu
ifeiwu / lighten-darken-color.js
Last active Jun 27, 2021
颜色明暗度调整
View lighten-darken-color.js
var LightenDarkenColor = function(col, amt) {
var usePound = false;
if (col[0] == "#") {
col = col.slice(1);
usePound = true;
}
var num = parseInt(col,16);
@ifeiwu
ifeiwu / image-zoom-with-mouse-movements.js
Last active Jun 27, 2021
图片放大跟随鼠标移动
View image-zoom-with-mouse-movements.js
$(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(),
@ifeiwu
ifeiwu / color-to-hex.js
Last active Jun 27, 2021
颜色RGB转HEX
View color-to-hex.js
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 / jquery-iframe-auto-height.js
Last active Jun 27, 2021
jQuery自动调整iframe页面高度
View jquery-iframe-auto-height.js
$(function() {
var height, _height;
setInterval(function(){
height = $(document.body).height();
if (height != _height){
_height = height;
$(parent.document.body).find("#testifr").height(height);
}
}, 0);
});
View multi-text-swipe-up-to-switch.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>多文字向上滑动切换</title>
<link rel="stylesheet" href="../reset.css" />
<style>
.textbox {