css/js(工作中遇到的问题)-2
iOS6 中的 apple-itunes-app tag
//iOS6, safari才有效
<meta
name="apple-itunes-app"
content="
app-id=myAppStoreID,
affiliate-data=myAffiliateData,
app-argument=myURL"
>
IOS判读user-agent
if (/xxxx/.test(req.headers['user-agent']))
返回的状态码
- 要团队约定;一般删除成功返回204,其他成功返回200;
css自适应
- 设置高度自适应
#one {
position: absolute;
width: 100%;
top: 0;
height: percentage(1/8);
}
#two {
position: absolute;
width: 100%;
top: percentage(1/8);
height: percentage(4/8);
}
#three {
position: absolute;
width: 100%;
top: percentage(1/8 + 4/8);
height: percentage(2/8);
}
#four {
position: absolute;
width: 100%;
top: percentage(1/8 + 4/8 + 2/8);
bottom: 0;
}
- 居中
.centered (@horizontal: 0, @vertical: 0) {
left: @horizontal;
top: @vertical;
transform: translate(-@horizontal, -@vertical);
-webkit-transform: translate(-@horizontal, -@vertical);
-ms-transform: translate(-@horizontal, - @vertical);
}
- 设置背景图片
.bgImg(@url: '0') {
background-repeat: no-repeat;
background-size: 100% 100%;
background-image: url(@url);
}
一个屏障效果
.modal {
position: fixed;
z-index: 999;
top: 0;
height: 120%;
width: 100%;
background-color: rgba(0,0,0,.5);
-webkit-animation-duration: .14s;
animation-duration: .14s;
}
常用的正则验证
一个css书页折叠效果原型
.example {
width: 0;
height: 0;
border-bottom: 100px solid black;
border-left: 100px solid red;
/*transform: skewX(18deg);*/
}
判断数字类型
isNaN(Number(id)) || isNaN(parseInt(id))
获取ip地址(nodejs)
export default function getClientIp(req) {
let ipAddress, forwardedIpsStr = req.headers['x-forwarded-for'];
forwardedIpsStr && (ipAddress = forwardedIpsStr.split(',')[0]);
!ipAddress && (ipAddress = req.connection.remoteAddress || req.socket.remoteAddress);
return ipAddress;
};
less文件中键入css文件
@import (inline) "../normalize.css";
制作linear-gradient背景
.gradient (@startColor, @endColor) {
background: linear-gradient(135deg, @startColor 50%, @endColor 50%);
background: -webkit-linear-gradient(135deg, @startColor 50% , @endColor 50%);
background: -moz-linear-gradient(135deg, @startColor 50% , @endColor 50%);
background: -ms-linear-gradient(135deg, @startColor 50% , @endColor 50%);
background: -o-linear-gradient(135deg, @startColor 50% , @endColor 50%);
background-color: @startColor;
}
判断元素是否在当前屏幕内
var body = document.body;
var win = getViewport();
var info = document.getElementById('info');
var box = document.getElementById('box');
function getViewport() {
// http://andylangton.co.uk/blog/development/get-viewport-size-width-and-height-javascript
var e = window,
a = 'inner';
if (!('innerWidth' in window)) {
a = 'client';
e = document.documentElement || body;
}
return {
width: e[a + 'Width'],
height: e[a + 'Height']
};
}
function getCurPos() {
var pos = box.getBoundingClientRect();
if (pos.top > win.height) {
info.innerText = '我在下面';
} else if (pos.bottom < 0) {
info.innerText = '我在上面';
} else if (pos.left > win.width) {
info.innerText = '我在右边';
} else if (pos.right < 0) {
info.innerText = '我在左边';
} else {
info.innerText = '我在当前屏';
}
}
window.addEventListener('scroll', getCurPos, false);
window.addEventListener('resize', function() {
win = getViewport();
getCurPos();
}, false);
去除inline-block间隙
关于透明度
*设置了opacity后,子元素会继承且不能重写;使用rgba;
调用原生混合中的webview暴露的方法时
- 注意可能上下文变化
var redirect = (typeof JavaScriptInterface === 'object') ? (function (func) {
return function () {
return func.apply(JavaScriptInterface, arguments)
}
})(JavaScriptInterface.redirectTo) : redirectTo ;
生成三角形
border-width;background: linear-gradient();
//生成环形凹角标
background: #58a;
background:
radial-gradient(circle at top left,
transparent 15px, #58a 0) top left,
radial-gradient(circle at top right,
transparent 15px, #58a 0) top right,
radial-gradient(circle at bottom right,
transparent 15px, #58a 0) bottom right,
radial-gradient(circle at bottom left,
transparent 15px, #58a 0) bottom left;
background-size: 50% 50%;
background-repeat: no-repeat;
旋转
transform: rotate(-45deg);
transform: skewX(-45deg);
css/js(工作中遇到的问题)-2的更多相关文章
- css/js(工作中遇到的问题)-4
JS生成随机的由字母数字组合的字符串 Math.random().toString(36).substr(2)
- css/js(工作中遇到的问题)-3
设置宽高比 使用padding/margin-top/bottom; 设置出教准确的自适应布局; 用于预加载图片; 关于数据库设置 添加extra对象用于扩展; 添加type类型; 对于字体 使用百分 ...
- css/js(工作中遇到的问题)-6
页面resize方法 if(document.createEvent) { const event = document.createEvent ("HTMLEvents"); e ...
- css/js(工作中遇到的问题)-5
后端换行符处理 问题描述 // Windows new line support (CR+LF, \r\n) str = str.replace(/\r\n/g, "\n"); 遍 ...
- css/js(工作中遇到的问题)
移动设备点击时去掉外加的蓝色边框 a, input, button { -webkit-tap-highlight-color: rgba(0,0,0,0); -webkit-tap-highligh ...
- css布局 - 工作中常见的两栏布局案例及分析
突然想到要整理这么一篇平时工作中相当常见但是我们又很忽视的布局的多种处理方法.临时就在我经常浏览的网站上抓的相对应的截图.(以后看到其他类型的我再补充) 既然截了图,咱们就直接看人家使用的布局方式,毕 ...
- js工作中编程习惯
在前端编程中总结的习惯不管js还是css 还是后端开发这几点都是必须要做到的做好这几点不管去什么公司都是受到别人的尊重 善用变量,尤其是对DOM结构中的ID以及CLASS 多写注释,自己不熟,前面写后 ...
- js工作中日常问题集中
1.判断问题 如果type存在就设置type的值为type,否则设置type为0: 原始的写法,使用 if else:if(type){type = type} 使用三元操作符:type : type ...
- 用 Flask 来写个轻博客 (28) — 使用 Flask-Assets 压缩 CSS/JS 提升网页加载速度
Blog 项目源码:https://github.com/JmilkFan/JmilkFan-s-Blog 目录 目录 前文列表 扩展阅读 Flask-Assets 将 Flask-Assets 应用 ...
随机推荐
- 【python】正则中的group()
来源:http://www.cnblogs.com/kaituorensheng/archive/2012/08/20/2648209.html 正则表达式中,group()用来提出分组截获的字符串, ...
- POJ 2965 The Pilots Brothers' refrigerator
题目链接 题意:一个冰箱上有4*4共16个开关,改变任意一个开关的状态(即开变成关,关变成开)时,此开关的同一行.同一列所有的开关都会自动改变状态.要想打开冰箱,要所有开关全部打开才行. 输入:一个4 ...
- [聊天框]让DIV的滚动条自动滚动到最底部 - 4种方法
要制作一个在线聊天的程序,在做最后的修饰时,需要对获得的信息即时滚动以保证用户总能看到最新消息. 聊天程序是基于AJAX设计的,没有用框架,消息容器是一个DIV,所以问题就在于如何控制DIV的滚动条. ...
- bootstrap弹出提示窗口功能
大家常用弹出提示成功或失败时候喜欢用alert,如果不用这个,写个弹窗又麻烦,bootstrap中就有个方法 alert("操作成功"); commonAlert("操作 ...
- .Net的DataGrid的使用
先上图吧
- (转)Ehcache 整合Spring 使用页面、对象缓存
Ehcache在很多项目中都出现过,用法也比较简单.一般的加些配置就可以了,而且Ehcache可以对页面.对象.数据进行缓存,同时支持集群/分布式缓存.如果整合Spring.Hibernate也非常的 ...
- 4.3 map和multimap
使用map multimap必须包含头文件map *:multimap 1)multimap定义 template<class Key,class Pred=less<Key>,cl ...
- 四、优化及调试--网站优化--Yahoo军规上
什么是Yahoo军规?即如何提高网站速度的知识. 具体如下: 1.尽量减少HTTP请求个数——须权衡 什么是http请求:从客户端到服务器端的请求消息.包括消息首行中,对资源的请求方法,资源的标识符及 ...
- 按键消抖-----verilog
实际系统中常用的按键大部分都是轻触式按键,如下图所示.该按键内部由一个弹簧片和两个固定触点组成,当弹簧片被按下,则两个固定触点接通,按键闭合.弹簧片松开,两个触点断开,按键也就断开了.根据这种按键的机 ...
- 《C#本质论》读书笔记(12)委托和Lambda表达式
12.1.委托概述 12.1.2 委托的数据类型 为了减少重复代码数量,可以将比较方法作为参数传递给 BubbleSort()方法.此外,为了将方法作为参数传递,必须有一个能够标识方法的数据类型--也 ...