|
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
拉取远端仓库代码: 如果本地已经存在文件夹,先cd进去,然后敲命令: git fetch (作用是拉取远端仓库里的代码) git merge (作用是将远端仓库里的代码与本地仓库里的代码合并,如果有冲突会提示,这时候需要讲不正确的代码删除) 提交本地仓库的代码到远端仓库: git status (作用是查看仓库的状态) git add . (监控本地仓库的状态树,将本地仓库的所有变化提交到暂存区,包括文件内容修改modified以及新文件new,但是不包括被删除的文件) || git add -u(小写的u,仅监控已经被add的文件(即 tracked file),会将被修改的文件提交到暂存区。add -u不会提交新文件(untracked file) || git add -A (是前面两个功能的集合) git commit -m"备注信息" (作用是将代码提交到本地仓库) git log (查看git日志) git push (作用是将代码提交到远端服务器仓库) 这时候如果提示有冲突的话,我们就需要执行 git fetch 和 git merge 命令了,处理完冲突以后再重新push。 如果是第一次向远端仓库提交代码,需要执行以下命令: 首先要进入项目的文件夹,然后 git init (作用是创建本地仓库,加将会在文件夹下创建一个 .git 文件夹,.git 文件夹里存储了所有版本信息、标记等内容。注:如果整个项目文件夹是拷贝过来的,这时候需要先将文件夹内的 .git 文件夹删除后再执行init) git remote add origin git@192.168.19.154:TG/zhibo.git(作用是将本地仓库与远程仓库关联起来。如果不执行这个命令的话,每次push的时候都要指定远程服务器的地址。) 然后再执行提交命令。 版本回退: git reset --hard HEAD^ //回退到上个版本 git reset --hard HEAD^^ //回退到上上个版本 git reset --hard HEAD~100 //回退到前100个版本 git reflog //查看版本信息 git reset --hard 版本号 //回退到指定版本 用户名和邮箱: git config user.name //查看当前用户名 git config user.email //查看当前邮箱 git config --global user.name "your name that want to change" // 更改用户名 git config --global user.email xxx@xxx.com // 更改邮箱 操作远程仓库: git remote -v //查看当前仓库 git remote add <name> <url> //添加远程仓库 git remote set-url <name> <url> //切换远程仓库地址 git remote rm <name> //删除远程仓库 |
作者:SKILLNULL
解决css3毛玻璃效果(blur)有白边问题
|
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
做一个登录页,全屏背景图毛玻璃效果,实现方法如下: HTML: <body> <div class="login-wrap"> <div class="login-mask"></div> <div class="login-box"></div> </div> <script> var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; $('.login-mask').css("height", h); $('.login-mask').css("width", w); </script> </body> CSS: .login-wrap { overflow: hidden; } .login-mask { /* IE6~IE9 */ filter: progid: DXImageTransform.Microsoft.Blur(PixelRadius=100, MakeShadow=false); -webkit-filter: blur(100px); -moz-filter: blur(100px); -ms-filter: blur(100px); filter: blur(100px); background-image: url(../../../img/background/home-bg-3.jpg); background-repeat: no-repeat; background-size: cover; background-attachment: fixed; background-position: center; position: absolute; z-index: 1; } .login-box { width: 300px; height: 400px; background-color: rgba(255, 255, 255, 0.5); display: block; border: 1px solid rgba(183, 183, 183, 0.47); border-radius: 6px; position: absolute; left: 50%; margin-right: auto; margin-left: -150px; margin-top: 10%; z-index: 2; } |
效果如下:


可以发现边上是有白边的,这是一种blur的值很大的情况下。此时的解决方法是直接将background-size:cover;改成background-size:150% 150%;就行了。
效果图如下:

仔[……]
ajax循环读取json多维数组
|
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
test.json: { "one": [ { "name": "黑默丁格", "car": "鲁LLL608", "mobil": "15666666666", "mount": "1", "time": "2016-07-13", "cat": "保养", "state": "有效", "message":"长安福特4S店温馨提醒:是时候给您的爱车去做保养了。" }, { "name": "EZ", "car": "鲁LLL608", "mobil": "15666666666", "mount": "1", "time": "2016-07-13", "cat": "保养", "state": "有效", "message":"长安福特4S店温馨提醒:是时候给您的爱车去做保养了。" } ], "two": [ { "name": "机器人", "car": "鲁LLL608", "mobil": "15666666666", "mount": "1", "time": "2016-07-13", "cat": "保养", "state": "有效", "message": "长安福特4S店温馨提醒:是时候给您的爱车去做保养了。" }, { "name": "贾克斯", "car": "鲁LLL608", "mobil": "15666666666", "mount": "1", "time": "2016-07-13", "cat": "保养", "state": "有效", "message":"长安福特4S店温馨提醒:是时候给您的爱车去做保养了。" } ] } |
ajax:

效果:


禁止微信内置浏览器调整字体大小
|
1 2 3 4 5 6 7 8 9 10 |
微信webview内置了调整字体大小的功能,用户可以根据实际情况进行调节。 但是这也会导致字体大小改变以后,出现页面布局错乱的情况, 目前iOS的解决方案是覆盖掉微信的样式: body { /* IOS禁止微信调整字体大小 */ -webkit-text-size-adjust: 100% !important; } 安卓的解决方案是通过 WeixinJSBridge 对象将网页的字体大小设置为默认大小, 并且重写设置字体大小的方法,让用户不能在该网页下设置字体大小: |
|
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
/* * android禁止微信浏览器调整字体大小 * 这种方法会导致网页延迟大约1S */ (function () { if (typeof WeixinJSBridge == "object" && typeof WeixinJSBridge.invoke == "function") { handleFontSize(); } else { if (document.addEventListener) { document.addEventListener("WeixinJSBridgeReady", handleFontSize, false); } else if (document.attachEvent) { document.attachEvent("WeixinJSBridgeReady", handleFontSize); document.attachEvent("onWeixinJSBridgeReady", handleFontSize); } } function handleFontSize() { // 设置网页字体为默认大小 WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize': 0 }); // 重写设置网页字体大小的事件 WeixinJSBridge.on('menu:setfont', function () { WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize': 0 }); }); } })(); |
ajax+php+mysql 实现点赞、局部刷新,每个IP只能对一篇文章点赞一次
|
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
主要流程: 点赞—>判断当前设备IP是否对当前文章有过点赞记录—>若有记录,弹出提示“已经赞过了”; 若无记录,当前文章点赞数+1,并在记录设备IP点赞记录的表中插入信息。 文章表 article 必不可少的字段:article_id(必须设置为自增), cat_id, praise 图文表 image_article 必不可少的字段:article_id(必须设置为自增), cat_id, praise 设备IP点赞记录表 client_ip 必不可少的字段:id(必须设置为自增), article_id, cat_id, ip HTML部分: ({$sentence.praise}) JS部分( praise.js ): $(function (){ $(".praise").click(function () { var praise = $(this); var article_id = praise.attr("rel");//获取HTML页面POST过来的article_id var cat_id = praise.attr("rev");//获取HTML页面POST过来的cat_id $.ajax({ type: "POST", url: "praise.php", data: "article_id=" + article_id + "&cat_id=" + cat_id,//数据拼接 cache: false,//不缓存此页面 success: function (data) { praise.html(data);//显示data并局部刷新 }, error: function () { alert("error"); } }); }); }); PHP部分( praise.php ): <?php $connect = mysql_connect("数据库地址","数据库用户名","数据库密码");//链接数据库 if (!$connect){die('Could not connect: ' . mysql_error());} mysql_select_db("数据库名称",$connect);//选择数据库 $ip = $_SERVER["REMOTE_ADDR"];//获取终端IP $article_id = $_POST['article_id'];//获取article_id $cat_id = $_POST['cat_id'];//获取cat_id if (!isset($article_id) || empty($article_id) & !isset($cat_id) || empty($cat_id)) exit;//检测变量是否设置 $look = "select ip from client_ip where article_id='$article_id' and cat_id='$cat_id' and ip='$ip'"; $ip_look = mysql_query($look, $connect); //查询client_ip表中是否存在当前终端IP $count = mysql_num_rows($ip_look); //返回查询结果的记录数目 if ($count == 0) { //如果没有记录 $up_praise = "update article set praise=praise+1 where article_id='$article_id' and cat_id='$cat_id'"; $result = mysql_query($up_praise, $connect); //更新文章点赞数 $up_img_praise = "update image_article set praise=praise+1 where article_id='$article_id' and cat_id='$cat_id'"; $result = mysql_query($up_img_praise, $connect); //更新图文点赞数 $entry_in = "insert into client_ip (article_id,cat_id,ip) values ('$article_id','$cat_id','$ip')"; mysql_query($entry_in, $connect); //写入数据 } else { echo "<script>alert('已经赞过了');</script>"; } $new_praise = "select praise from article where article_id='$article_id' and cat_id='$cat_id'"; $look_new_praise = mysql_query($new_praise, $connect);//查询更新后的文章表点赞数 $new_img_praise = "select praise from image_article where article_id='$article_id' and cat_id='$cat_id'"; $look_new_img_praise = mysql_query($new_img_praise, $connect);//查询更新后的图文表点赞数 if ($arr = mysql_fetch_assoc($look_new_praise)) { $transform_arr[] = $arr;//将查询到的article表的prise转换成数组 } elseif ($arr = mysql_fetch_assoc($look_new_img_praise)) { $transform_arr[] = $arr;//将查询到的image_article表的prise转换成数组 } echo '(' . $transform_arr[0]['praise'] . ')';//打印数组值 mysql_close($connect);//关闭数据库 |
让textarea完全显示文章并且不滚动、不可拖拽、不可编辑
浏览器滚动条样式更改
|
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 27 28 29 30 31 32 33 34 |
::-webkit-scrollbar { // 滚动条整体部分 width: 6px; height: 8px; } ::-webkit-scrollbar-track { // 外层轨道 background-color: #eee; border-radius: 4px; } ::-webkit-scrollbar-track-piece { // 内层滚动槽 background-color: #eee; border-radius: 4px; } ::-webkit-scrollbar-thumb { // 滚动的滑块 background: rgba(32, 33, 36, 0.3); border-radius: 4px; } ::-webkit-scrollbar-thumb:hover { background: rgba(32, 33, 36, 0.4); width: 10px; } ::-webkit-scrollbar-corner { // 边角 display: none; } ::-webkit-scrollbar-button { // 滚动条两端的按钮 display: none; } 注:目前仅Chrome下生效 |
PHP获取当前位置
ThinkPHP动态版本控制
|
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
动态版本控制可以根据时间戳来实现,但是这样的话,每次打开页面都会重新下载加了版本控制的文件,如果你的页面自身打开本来就慢的话, 这样一来,无疑会带来很差的用户体验。 但是如果在每个引用文件后面都手动加上版本,如果页面比较多的话,这很明显是个很蠢的做法,所以我们可以这样做: (1)在入口文件定义公共模块: define('COMMON_PATH','./Common/'); 然后将Home文件夹下的Common剪切出来,放在和入口文件同目录。 (2)在Common-->Conf-->config.php中配置一个数组: <?php return array( //CSS版本控制 'cssVersion' => '1.0', 'cssVersionid' => '1.0', //JS版本控制 'jsVersion' => '1.0', 'jsVersionid' => '1.0', ); (3)在控制器中引入 <?php namespace Home\Controller; use Think\Controller; class IndexController extends Controller { public function index(){ /* 版本控制 */ $config = require(COMMON_PATH.'Conf/config.php'); this−>assign(′cssVersionid′,config['cssVersionid']); this−>assign(′jsVersionid′,config['jsVersionid']); /* 页面显示 */ $this->display(); } } 当然所有的assign必须放在$this->display();前面。在thinkPHP3.2.3中,你也可以这样写: <?php namespace Home\Controller; use Think\Controller; class IndexController extends Controller { public function __construct(){ /* 版本控制 */ parent::__construct(); $config = require(COMMON_PATH.'Conf/config.php'); this−>assign(′cssVersionid′,config['cssVersionid']); this−>assign(′jsVersionid′,config['jsVersionid']); } public function index(){ /* 页面显示 */ $this->display(); } } (4)这时候就可以在HTML页面引入了 <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/page/index.css?v={$cssVersionid}"> <script src="__PUBLIC__/js/page/index.js?v={$jsVersionid}"></script> 这样一来,每次有更新的话,只需要手动在config.php更改版本就行了,而且可以只更新CSS或JS其中一个。 |

。