1 2 3 4 5 6 7 8 9 10 11 |
textarea { width: 100%; border: none; outline: none; resize: none; overflow: hidden; padding-bottom: 100%; background-color: inherit; } <textarea readonly="readonly"></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下生效 |
图片加载失败显示默认图片占位符
JS根据不同浏览器(分辨率)调用不同css
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 |
根据不同浏览器: <script type="text/javascript"> var version = navigator.userAgent; if (version.indexOf("MSIE") > 1) { document.write("<link href='ie.css' rel='stylesheet' type='text\/css'\/>"); } else if (version.indexOf("Chrome") > 1) { document.write("<link href='chrome.css' rel='stylesheet' type='text\/css'\/>"); } else if (version.indexOf("Firefox") > 1) { document.write("<link href='ff.css' rel='stylesheet' type='text\/css'\/>"); } </script> 根据不同分辨率: <script type="text/javascript"> if (screen.width == 1024){ document.write("<link href='css/css1.css' rel='stylesheet' type='text\/css'\/>"); }else { document.write("<link href='css/css2.css' rel='stylesheet' type='text\/css'\/>");} </script> |
为 placeholder 自定义样式
关于HTML5在动画制作工具Animatron的一些问题
在HTML中禁止文字的复制
JS返回上一页
当一个页面出现多个checkbox全选时的处理
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
HTML: <input type="checkbox" onclick="boxOnclick(this,'some1')">全选一 <input type="checkbox" onclick="boxOnclick(this,'some2')">全选二 <input type="checkbox" onclick="boxOnclick(this,'some3')">全选三 <input type="checkbox" class="some1">全选一的子集 <input type="checkbox" class="some2">全选二的子集 <input type="checkbox" class="some3">全选三的子集 JS: function boxOnclick(obj, someNum) { if (obj.checked) { $("." + someNum).each(function () { this.checked = true; }); } else { $("." + someNum).each(function () { this.checked = false; }); } } |
JS获取浏览器高度 并赋值给类
1 2 3 4 5 6 7 8 9 10 11 12 |
var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; 如果你需要给某个div设置全屏的话,可以用下面的jQuery来获取设备高度,然后赋值给类。 $(window).load(function () { var maxHeight = 0; if (document.documentElement.clientHeight > maxHeight) { maxHeight = document.documentElement.clientHeight; } $('.you-class').css("height", maxHeight) }); |