heguichuan

Go Hiking


  • 首页

  • 归档

  • 标签

设置input placeholder颜色

发表于 2018-05-12

参考链接:使用CSS修改HTML5 input placeholder颜色

css方式

WebKit和Blink(Safari,Google Chrome, Opera15+)使用伪元素:

::-webkit-input-placeholder

Mozilla Firefox 4-18使用伪类

:-moz-placeholder

Mozilla Firefox 19+ 使用伪元素

::-moz-placeholder

IE10使用伪类

:-ms-input-placeholder

例子:

1
2
3
4
5
6
7
8
9
10
11
12
input::-webkit-input-placeholder, textarea::-webkit-input-placeholder {
color: #666;
}
input:-moz-placeholder, textarea:-moz-placeholder {
color: #666;
}
input::-moz-placeholder, textarea::-moz-placeholder {
color: #666;
}
input:-ms-input-placeholder, textarea:-ms-input-placeholder {
color: #666;
}

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
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
setPlaceholderColor: function(){
/* jqury版
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.addClass('placeholder');
input.val(input.attr('placeholder'));
}
}).blur();
$('[placeholder]').parents('form').submit(function() {
$(this).find('[placeholder]').each(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
}
})
});
*/
// 原生js
var inputList = document.querySelectorAll('[placeholder]');
var formList = new Set();
inputList.forEach(function(v,i){
v.addEventListener('focus', function(evt){
var input = evt.target;
if (input.value == input.placeholder) {
input.value = '';
input.classList.remove('placeholder');
}
});
v.addEventListener('blur', function(evt){
var input = evt.target;
if (input.value == '' || input.value == input.placeholder) {
input.classList.add('placeholder');
input.value = input.placeholder;
}
})
v.blur();
var parent = v.parentNode;
while (parent.tagName !== 'FORM' && parent.tagName !== 'BODY') {
parent = parent.parentNode;
}
if (parent.tagName === 'FORM') {
formList.add(parent);
}
})
formList.forEach(function(form){
form.addEventListener('submit', function(evt){
evt.target.querySelectorAll('[placeholder]').forEach(function(input){
if (input.value == input.placeholder) {
input.value = '';
}
})
})
})

}

loading-加载动画总结

发表于 2018-01-12

loading - 加载动画总结

onenet篇

1、表格内容加载动画

html:

1
2
3
4
5
loadingStr(colspan){
return '<tr style="width: 100%;text-align: center;"><td colspan="'+colspan+'">'
+ '<div class="load-wrapper loading-wrapper"><i class="icon-spin5 animate-spin"></i></div>'
+ '</td></tr>';
},

css:

引入common.less就可以。

2、页面加载动画

html:

1
2
3
4
5
6
7
8
9
10
11
_loadingDomStr () {
return $(['<div class="show-loading">',
'<div class="loading">',
'<div class="spin">',
'<div class="load">',
'<span></span><span></span><span></span>',
'</div>',
'</div>',
'</div>',
'</div>'].join(' '));
},

css:

1
2
3
4
5
6
7
8
9
10
11
12
@import url("/common/css/module/multislider.less");
.show-loading {
width: 100%;
height: 100px;
text-align: center;
line-height: 100px;
.loading {
position: absolute;
top: 50%; left: 50%;
transform: translate(-50%, -50%);
}
}

通用篇

主要是有三个开源库:

  1. SpinKit 可以直接拷贝demo代码,用哪个拷哪个很方便。
  2. loaders.css 另外一个实现,有react、vue等版本。
  3. loading svg动画。

在线生成loading的网站:https://loading.io/

移动端页面开发学习笔记

发表于 2018-01-12

移动端页面开发学习笔记

基本思路

参考链接:再聊移动端页面的适配

总结出来就是:

  • 使用vw来实现页面的适配,并且通过PostCSS的插件postcss-px-to-viewport把px转换成vw。这样我们可以直接使用px单位,插件帮我们自动转换。
  • 为了跟好的实现长宽比,特别是针对于img/vedio/iframe元素,通过PostCSS插件postcss-aspect-ratio-mini来实现,在实际使用中,只需要把对应的宽高写进去即可。
  • 为了解决1px问题,使用PostCSS插件postcss-write-svg,自动生成border-image或者background-image的图片。

*可以使用vw的地方*:

  • 容器适配
  • 文本适配
  • 大于1px的边框、圆角、阴影
  • 内距和外距

插件的使用

postcss-px-to-viewport

1
yarn add postcss-px-to-viewport

配置如下:webpack+vue(vue-cli)

1
2
3
4
5
6
7
8
9
10
11
postcss: [
require('postcss-px-to-viewport')({
viewportWidth: 375, //px 可以直接设置为设计稿的宽度,然后开发中就可以直接使用px做单位。
viewportHeight: 667, //高
unitPrecision: 5, //精度
viewportUnit: 'vw',
selectorBlackList: [],
minPixelValue: 1,
mediaQuery: false
})
]

手机使用电脑代理访问内网的姿势(实现手机修改host文件的效果)

发表于 2017-11-15

手机使用电脑代理访问内网的姿势(实现手机修改host文件的效果)

问题起源

passport的h5登录页面出现了一次mate9手机浏览器兼容问题,一般情况下手机无法修改host,以前没找到使用mate9在测试环境访问的方法,问题一直拖了很久没解决,直到某一天从同事那里知道了使用电脑代理的方式可以访问内网的网站,实现修改手机host文件的效果。

参考链接:使用fiddler4做代理调试手机页面

具体步骤

  1. 需要手机通过wifi链接电脑,如果是台式电脑可以买一个外接网卡(最便宜的就可以了)。
  2. 手机链接wifi后,需要给手机wifi配置代理,添加主机名(就是wifi中的路由器栏的地址)和端口(fiddler默认监听的端口,默认8888)。
  3. 下载安装fiddler4,具体配置见参考链接。
  4. 电脑修改host,手机访问域名体验效果。

nvm学习笔记

发表于 2017-05-12

nodejs版本管理工具——nvm学习笔记

windows版本

下载安装:地址,windows下直接安装。

使用:

1
2
3
4
5
6
7
#常用命令
nvm list #列出已安装版本
nvm list available #列出可安装版本
nvm install <version> #安装指定版本号
nvm uninstall <version> #安装指定版本号
nvm use <version> #使用指定版本号
node -v #查看当前node版本号
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
#帮助
E:\360Downloads\nvm-setup>nvm

Running version 1.1.5.

Usage:

nvm arch : Show if node is running in 32 or 64 bit mode.
nvm install <version> [arch] : The version can be a node.js version or "latest
" for the latest stable version.
Optionally specify whether to install the 32 or
64 bit version (defaults to system arch).
Set [arch] to "all" to install 32 AND 64 bit ve
rsions.
Add --insecure to the end of this command to by
pass SSL validation of the remote download server.
nvm list [available] : List the node.js installations. Type "available
" at the end to see what can be installed. Aliased as ls.
nvm on : Enable node.js version management.
nvm off : Disable node.js version management.
nvm proxy [url] : Set a proxy to use for downloads. Leave [url] b
lank to see the current proxy.
Set [url] to "none" to remove the proxy.
nvm node_mirror [url] : Set the node mirror. Defaults to https://nodejs
.org/dist/. Leave [url] blank to use default url.
nvm npm_mirror [url] : Set the npm mirror. Defaults to https://github.
com/npm/npm/archive/. Leave [url] blank to default url.
nvm uninstall <version> : The version must be a specific version.
nvm use [version] [arch] : Switch to use the specified version. Optionally
specify 32/64bit architecture.
nvm use <arch> will continue using the selected
version, but switch to 32/64 bit mode.
nvm root [path] : Set the directory where nvm should store differ
ent versions of node.js.
If <path> is not set, the current root will be
displayed.
nvm version : Displays the current running version of nvm for
Windows. Aliased as v.

hexo使用笔记

发表于 2017-03-13

hexo使用笔记

安装

1
npm install -g hexo-cli

常用命令

1
2
3
4
hexo new [layout] <title> #写新文章
hexo g #生成
hexo server #本地运行
hexo deploy #部署

部署配置

git方式

安装: npm install hexo-deployer-git --save

修改_config.yml文件:

1
2
3
4
deploy:
type: git
repository: git@github.com:heguichuan/heguichuan.github.io.git
branch: master
<i class="fa fa-angle-left"></i>12

16 日志
9 标签
© 2021 heguichuan
由 Hexo 强力驱动
主题 - NexT.Muse