让超大banner图片不拉伸、全屏宽、居中显示的方法

方法一:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<html>
<head>
<title>让超大banner图片不拉伸、全屏宽、居中显示的方法</title>
<style>
.bannerbox {
width:100%;
position:relative;
overflow:hidden;
height:525px;/*banner高度*/
}

.banner {
width:1600px;/*banner宽度*/
position:absolute;
left:50%;
margin-left:-800px;/*负banner宽度的一半*/
}

</style>

</head>
<body>
<div class="bannerbox">
<div class="banner">
<img src="banner.jpg">
</div>
</div>
</body>
</html>

注:把css中 .bannerbox 中 height 及 .banner 和 width 换成你banner图的大小,然后 .banner 中margin-left 的值改成banner图宽度的一半即可。

方法二:


阅读全文 >>

js全选/全不选

方法一:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>全选/全不选1</title>
<script src="http://libs.baidu.com/jquery/1.8.3/jquery.min.js"></script>
</head>
<body>
<input type="checkbox" class="allcheck">全选/全不选<br>
<input type="checkbox" class="subcheck">
<input type="checkbox" class="subcheck">
<input type="checkbox" class="subcheck">
<input type="checkbox" class="subcheck">
<input type="checkbox" class="subcheck">

<script>
$(function(){
$(".allcheck").click(function(){
$(".subcheck").prop("checked",$(".allcheck").prop("checked"));
});
});
</script>

</body>
</html>

方法二:


阅读全文 >>

document.ready=function(){}和$(function(){})和window.onload=function(){}区别

一、window.onload=function(){};

  1. 是js原生写法,意思是带文档完全加载完毕后再执行其中的代码。
  2. 只能写一个,各种函数都可以写在这里面。

二、$(function(){})

  1. 是依赖于jQuery的,是$(document).ready(function(){})的简写。
  2. 不需要等文档完全加载,只需文章结构加载完就能执行其中的代码。
  3. 可以写多个,按顺序执行。

三、document.ready=function(){}

  1. 也是依赖于jQuery的。
  2. 相当于$(function(){}),但优先级没有$(function(){})高,从下面的例子就可以看出:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    <script>
    document.ready=function(){
    alert(1);
    };

    $(function(){
    alert(2);
    });

    $(function(){
    alert(3);
    });

    //输出的顺序为2 3 1
    </script>

四、(function(){})();

注:如有不正确的地方和不完整之处,希望小伙伴们呢能给指正!


end

通过ssh方式连接到别人的远程仓库分支并且提交项目文件到该分支下

方法步骤:

  1. 本地新建仓库:

    1
    git init
  2. 创建密钥:

    1
    ssh-keygen -t rsa -C "285655496@qq.com"
  3. 绑定密钥,将创建好的密钥文件id_rsa.pub(在用户目录/.ssh/下)里面的内容复制粘贴到对方github账号的SSH keys中。

  4. 验证密钥:

    1
    ssh -T git@github.com
  5. 新建用户

    1
    git config --global user.name "ziyao"
    git config --global user.email "285655496@qq.com"
  6. clone远程仓库的项目到本地 git clone

  7. 本地修改项目、提交
    1
    git add .
    git commit
    git push -u origin master	第一次commit的时候要加-u

end