以下是常用的代码收集,没有任何技术含量,只是填坑的积累。转载请注明出处,谢谢。

1. css 2.x

  • 文字换行
/*强制不换行*/
white-space:nowrap;
/*自动换行*/
word-wrap: break-word;
word-break: normal;
/*强制英文单词断行*/
word-break:break-all;
  • 两端对齐
text-align:justify;text-justify:inter-ideogra
  • 去掉Webkit(chrome)浏览器中input(文本框)或textarea的黄色焦点框
input,button,select,textarea{ outline:none;}
textarea{ font-size:13px; resize:none;}
  • 去掉chrome记住密码后自动填充表单的黄色背景
  • ie6: position:fixed
.fixed-top /* position fixed Top */{position:fixed;bottom:auto;top:0; }
* html .fixed-top /* IE6 position fixed Top */{position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop));}
*html{background-image:url(about:blank);background-attachment:fixed;}
  • clearfix
.clearfix:after{visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0;}
.clearfix{display:inline-block;}
html[xmlns] .clearfix{display:block;}
* html .clearfix{height:1%;}

.clearfix{*zoom: 1;}
.clearfix:after{clear:both;display:table;content:"”;}

.clearfix{overflow:hidden;_zoom:1;}
  • seperate-table
.tab{border-collapse:separate;border:1px solid #e0e0e0;}
.tab th,.tab td{padding:3px;font-size:12px;background:#f5f9fb;border:1px solid;border-color:#fff #deedf6 #deedf6 #fff;}
.tab th{background:#edf4f0;}
.tab tr.even td{background:#fff;}
<table class="tab" width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <th>111</th>
        <td>222</td>
    </tr>
    <tr>
        <th>111</th>
        <td>222</td>
    </tr>
</table>
  • min-height: 最小高度兼容代码
.minheight500{min-height:500px;height:auto !important;height:500px;overflow:visible;}
  • 鼠标不允许点击
cursor:not-allowed;
  • mac font: osx平台字体优化
font-family:"Hiragino Sans GB","Hiragino Sans GB W3",‘微软雅黑‘;
  • 文字过多后显示省略号
.ellipsis,.ell{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

2. css 3

  • title 换行

  • 关闭 x 符号
×
  • 投影
.b{box-shadow:inset 1px -1px 0 #f1f1f1;text-shadow:1px 1px 0px #630;}
filter:progid:DXImageTransform.Microsoft.gradient(enabled=‘true‘,startColorstr=‘#99000000‘,endColorstr=‘#99000000‘);background:rgba(0,0,0,.6);

background:rgba(0,0,0,0.5);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=‘#50000000‘,endColorstr=‘#50000000‘)\9;
  • search占位
::-webkit-input-placeholder {}
::-moz-input-placeholder {}
input:focus::-webkit-input-placeholder { color: transparent; }
-webkit-appearance:none;  google边框去除
input[type="search"]{-webkit-appearance:textfield;} // 去除chrome默认样式
http://i.wanz.im/2011/02/04/remove_border_from_input_type_search/
http://blog.csdn.net/do_it__/article/details/6789699
line-height: normal; /* for non-ie */
line-height: 22px\9; /* for ie */
  • 全部浏览器的兼容代码生成 CSS 实现 textArea 的 placeholder 换行
  • 阻止默认事件
pointer-events:none;
  • 去掉输入框聚焦时候的白色背景
-webkit-user-modify: read-write-plaintext-only;
  • input:focus时input不随软键盘升起而抬高的情况
 :focus{-webkit-tap-highlight-color:rgba(255, 255, 255, 0);
 -webkit-user-modify:read-write-plaintext-only;}
  • 变灰 gray
html{
    filter: grayscale(100%);
    -webkit-filter: grayscale(100%);
    -moz-filter: grayscale(100%);
    -ms-filter: grayscale(100%);
    -o-filter: grayscale(100%);
    filter: url("data:image/svg+xml;utf8,<svg xmlns=\‘http://www.w3.org/2000/svg\‘><filter id=\‘grayscale\‘><feColorMatrix type=\‘matrix\‘ values=\‘0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\‘/></filter></svg>#grayscale");
    filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
    -webkit-filter: grayscale(1);
}
  • firefox 阻止选中
-moz-user-focus:ignore;-moz-user-input:disabled;-moz-user-select:none;
  • 箭头
display:block;border:solid transparent;line-height: 0;width:0; height:0;border-top:solid #0288ce;border-width:8px 6px 0 6px;

border-style:solid; border-width:7px; border-color:transparent transparent transparent #ff7020;
position:absolute;top: 0;left: 0;border-width:20px;border-style:solid;border-color:#d1ddde transparent transparent #d1ddde;

ie6 bug测试,把border-style设为dashed.

  • 取消textarea右下角可拖动手柄
resize:none
  • 取消chrome form表单的聚焦边框
input,button,select,textarea{outline:none}
textarea{resize:none}
  • 取消a链接的黄色边框
a{-webkit-tap-highlight-color:rgba(0,0,0,0);}
  • webkit 水平居中
display:-webkit-box;-webkit-box-pack:center; -webkit-box-align: center;
position:absolute; top:50%;left:50%;transform:translate(-50%,-50%);
  • 取消chrome 搜索x提示
input[type=search]::-webkit-search-decoration,
input[type=search]::-webkit-search-cancel-button,
input[type=search]::-webkit-search-results-button,
input[type=search]::-webkit-search-results-decoration {
    display: none;
}
  • chrome取消默认黄色背景
input:-webkit-autofill {-webkit-box-shadow: 0 0 0px 1000px white inset;}
input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px white inset;
}
autocomplete="off"
  • 手机版本网页a标记虚线框问题
a:focus {outline:none;-moz-outline:none;}
  • 焦点去除背景
-webkit-tap-highlight-color:rgba(255, 255, 255, 0);
-webkit-tap-highlight-color:transparent;  // i.e. Nexus5/Chrome and Kindle Fire HD 7‘‘
  • placeholder占位符颜色自定义
input:-moz-placeholder {color: #369;}
::-webkit-input-placeholder {color:#369;}
  • IOS 禁用高亮
-webkit-tap-highlight-color:rgba(255,0,0,0.5);-webkit-tap-highlight-color:transparent; /* For some Androids */
  • IOS iframe 滚动 滚动回弹特效
-webkit-overflow-scrolling:touch;overflow-y:scroll;
  • 禁止选中文本
-moz-user-select:none;
-webkit-user-select:none;
-ms-user-select:none;
user-select:none;
  • 模糊(毛玻璃)效果1
  • 模糊(毛玻璃)效果2
  • 模糊(毛玻璃)逼真效果
.blur {
    -webkit-filter: blur(10px); /* Chrome, Opera */
       -moz-filter: blur(10px);
        -ms-filter: blur(10px);
            filter: blur(10px);
}
<img src="mm1.jpg" />
<img src="mm1.jpg" class="blur" />
  • 显示旋转加载图片,下拉加载数据
#pullDown .pullDownIcon{display:inline-block;vertical-align:middle;width:40px;height:40px;background:url(https://github.com/chalecao/chale/blob/master/pull-icon%402x.png) 0 0 no-repeat;-webkit-background-size:40px 80px;background-size:40px 80px;-webkit-transition-property:-webkit-transform;-webkit-transition-duration:250ms}
#pullDown .pullDownIcon{-webkit-transform:rotate(0deg) translateZ(0)}
#pullDown .pullDownLabel{display:inline-block;vertical-align:middle;margin-left:5px;}
#pullDown.flip .pullDownIcon{-webkit-transform:rotate(-180deg) translateZ(0)}
#pullDown.loading .pullDownIcon{background-position:0 100%;-webkit-transform:rotate(0deg) translateZ(0);-webkit-transition-duration:0ms;-webkit-animation-name:loading;-webkit-animation-duration:2s;-webkit-animation-iteration-count:infinite;-webkit-animation-timing-function:linear}
@-webkit-keyframes loading{
    from{-webkit-transform:rotate(0deg) translateZ(0)}
    to{-webkit-transform:rotate(360deg) translateZ(0)}
}
<div id="pullDown" class="none loading">
    <span class="pullDownIcon"></span><span class="pullDownLabel">正在载入中...</span>
</div>
时间: 2024-08-07 07:47:49

以下是常用的代码收集,没有任何技术含量,只是填坑的积累。转载请注明出处,谢谢。的相关文章

常用的代码收集,没有任何技术含量,只是填坑的积累

以下是常用的代码收集,没有任何技术含量,只是填坑的积累.转载请注明出处,谢谢. 转自:https://github.com/jsfront/src/blob/master/js.md 1. PC - js 返回指定范围的随机数(m-n之间)的公式 Math.random()*(n-m)+m return false return false // event.preventDefault()会阻挡预设要发生的事件. // event.stopPropagation()会阻挡发生冒泡事件. //

DevExpress Grid控件经典常用功能代码收集

随着DevExpress 控件包越来越多的被中国用户使用,由于是英文版本,看英文版使用说明非常困难,慧都控件网在DevExpress 控件包使用方面有多年的研究,慧都控件网会不断的把DevExpress 使用经验分享给大家.»更多DevExpress开发资源与帮助文档 下面是我们平时收集最常用的DevExpress Winform 4个代码片段,比较常用,希望对广大DEV用户有帮助. 一 .GridControl的删除操作 private void rILinkEditInfoDel_Click

山大泰克条屏写串口的核心代码(海宏原创,转载请注明)

山大泰克条屏写串口的核心代码,海宏原创,转载请注明. using System; using System.Collections.Generic; using System.Text; // using System.Runtime.InteropServices; using System.IO.Ports; using System.Windows.Forms; using iPublic; namespace sdLed { /// <summary> /// 用来连接LED的API.

css 填坑常用代码分享

以下是常用的代码收集,没有任何技术含量,只是填坑的积累.转载请注明出处,谢谢. /*强制不换行*/ white-space:nowrap; /*自动换行*/ word-wrap: break-word; word-break: normal; /*强制英文单词断行*/ word-break:break-all; 2. 两端对齐 text-align:justify;text-justify:inter-ideogra 3. 去掉Webkit(chrome)浏览器中input(文本框)或texta

css 填坑常用代码分享[居家实用型]

原文地址 http://www.cnblogs.com/jikey/p/4233003.html 以下是常用的代码收集,没有任何技术含量,只是填坑的积累.转载请注明出处,谢谢. 一. css 2.x code 1. 文字换行 /*强制不换行*/ white-space:nowrap; /*自动换行*/ word-wrap: break-word; word-break: normal; /*强制英文单词断行*/ word-break:break-all; 2. 两端对齐 text-align:j

常用前端代码资源

转自https://github.com/jsfront/src/blob/master/css.md 以下是常用的代码收集,没有任何技术含量,只是填坑的积累.转载请注明出处,谢谢. 1. css 2.x 文字换行 /*强制不换行*/ white-space:nowrap; /*自动换行*/ word-wrap: break-word; word-break: normal; /*强制英文单词断行*/ word-break:break-all; 两端对齐 text-align:justify;t

初学git及用git将代码上传到新浪云的坑坑坑坑

一.坑之初始化(不初始化没法添加远程仓库) 1.你要是不进行初始化,git会报错:fatal: Not a git repository (or any of the parent directories): .git 如图: 2.要在代码文件夹的根目录下进行初始化------>$ git init 3.出现master时及成功或到文件夹的根目录下查看是否有隐藏的.git文件夹()如何查看隐藏的文件夹我就不多赘述了,大家都会) 此时初始化已完成! 二.上传代码(你可能会出现404错误)详情请访问

常用js代码整理、收集

个人整理了一下个人常用到的一些js代码,以方便学习以及日后使用,或许有一些是个人之前从网上摘下来的,但是不记得是具体从哪里来的了,如果你看到有一段代码跟你的文章很相似甚至一样,请不要气愤,请告诉我,我必定加上版权链接. 清除输入框默然提示文字 1 <input type="text" name="word" value='请输入关键字' style="color:#ccc;" /> 2 <script> 3 /* 4 *清

【cocos2dx 3.2】使用搜狗输入法短词,复用常用的代码段

引言: 在写cocos2dx代码的时候,发现有些代码是固定格式,经常要重用 故把它们不断收集起来,然后添加到搜狗输入法的短词里面 这样需要重用的时候,直接输快捷键,效率就提高了 把常用的代码段收集起来,做成一个CHM文档方便设置短词时查阅 搜狗输入法添加短词: 右键搜狗输入法,点击[设置属性] 选择[高级],然后选择右边的[自定义短语设置] 点击[添加新定义],添加自己的快捷键和代码段 常用的代码段(不断更新) 新建一个类的时候,需要写create方法和init方法,快捷键设为cre //创建c