用文字记录生活,留下美好瞬间
原创

你不知道的那些CSS属性

共 1,491 字,需阅读 4 分钟
2018/05/25 上午
1,285 次阅读

如何修改 input 输入框光标的颜色?

          
  • 1
  • 2
  • 3
input { caret-color: skyblue; }

如何修改 placeholder 的颜色?

          
  • 1
  • 2
  • 3
input:-webkit-input-placeholder { color: #ccc; }

移动端输入框获取焦点时显示搜索按钮?

          
  • 1
  • 2
  • 3
<form> <input type="search" /> </form>

移动端键盘如何显示纯数字?

          
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
<!-- 第一种方法 --> <form> <input type="tel" /> </form> <!-- 第二种方法 --> <form> <input type="text" pattern="[0-9]*" /> </form>

input如何自动获取焦点?

          
  • 1
<input type="text" autofocus="autofocus" />

IOS移动端自动关闭首字母大写?

          
  • 1
<input type="text" autocapitalize="off" />

禁止长按保存图片?

          
  • 1
  • 2
  • 3
img { -webkit-touch-callout: none; }

禁止长按选中文字?

          
  • 1
  • 2
  • 3
body { -webkit-user-select: none; }

如何去掉 button 按钮触摸时产生的半透明遮罩?

          
  • 1
  • 2
  • 3
a, button { -webkit-tap-highlight-color: rgba(0,0,0,0); }

文本域的 placeholder 如何换行?

常用转义字符表

字符 十进制 转义字符 描述
@ &#64 &commat 艾特符号
© &#169 &copy 版权符号
® &#174 &reg 注册商标符
¥ &#165 &yen 人名币符号
> &#62 &gt 大于号
< &#60 &lt 小于号
&#10 换行符
          
  • 1
  • 2
<!-- 使用转义字符 &#10; --> <textarea placeholder="文本域的 placeholder 如何换行, &#10;你明白了嘛?"></textarea>

谷歌浏览器如何显示更小的字体?

          
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
/* 使用transform进行缩放 */ span { font-size: 10px; transform: scale(0.8); }
本文于2018/05/25 上午发布在秘阁
#CSS
自由转载 - 署名 - 非商业性使用
https://zhangwurui.cn/article/8
0/0条看法
访客身份
在下有一拙见,不知...
期待你的捷足先登