Skip to content

Instantly share code, notes, and snippets.

@lionhylra
lionhylra / resize_img.css
Created October 5, 2013 11:53
图片缩放不超出原来大小
img{
width:auto;
max-width:100%;
}
@lionhylra
lionhylra / ajax.js
Created September 26, 2013 12:05
===AJAX===
$.ajaxSetup({
});
var jqxhr = $.ajax({
url: "http://fiddle.jshell.net/favicon.png",
type:"GET",//or "POST"
data:{name:"Jimy",age:22},//or data:"aSTring",
@lionhylra
lionhylra / opacity_toggle.js
Created September 26, 2013 06:14
透明度opacity
$('#nav nav').css("opacity", 0.8 );
$("#nav nav").on({
mouseenter: function () {
//$(this).addClass("mouseenter");
$(this).stop().animate({ opacity: 1 }, 200);
},
mouseleave: function () {
$(this).stop().animate({opacity: 0.8}, 500);
}
});
@lionhylra
lionhylra / list_file_name.php
Created September 24, 2013 10:06
遍历目录文件
<?php
if($handle = opendir('C:\\Inetpub\\wwwroot\\test\\')){
echo "Files:\n";
while (false !== ($file = readdir($handle))){
echo "$file\n";
}
closedir($handle);
}
?>
@lionhylra
lionhylra / vertical-align-center.css
Created September 18, 2013 08:11
vertical align-center: box-align: start|end|center|baseline|stretch;
div{
/*vertical align-center*/
/* Internet Explorer 10 */
display: -ms-flexbox;
-ms-flex-pack: center;
-ms-flex-align: center;
/* Firefox */
display: -moz-box;
-moz-box-pack: center;
-moz-box-align: center;
<!DOCTYPE html>
<html>
<head>
<script>
var xmlhttp;
function loadXMLDoc(url,cfunc)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
@lionhylra
lionhylra / jQuery.on.html
Created September 17, 2013 05:03
A jQuery way to change the style of element by changing the class
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>on demo</title>
<style>
.test {
color: #000;
padding: .5em;
border: 1px solid #444;
$( "p" ).clone().appendTo( document.body );
$( "p" ).clone().appendTo( document.body );
$( "p" ).clone().appendTo( document.body );
$( window ).scroll(function() {
$( "span" ).css( "display", "inline" ).fadeOut( "slow" );
});
@lionhylra
lionhylra / DocumentLoading.js
Created September 17, 2013 04:44
These three implementations are equivalent.
//1
$( document ).ready(function() {
// Handler for .ready() called.
});
//2
$(function() {
// Handler for .ready() called.
});
//3
jQuery( document ).ready(function( $ ) {
$.noConflict();
jQuery( document ).ready(function( $ ) {
// Code that uses jQuery's $ can follow here.
});
// Code that uses other library's $ can follow here.