一些经常用到的CSS小知识

157 阅读1分钟

1、ios弹性滚动:-webkit-overflow-scrolling:touch;


2、ios隐藏滚动条:

.${class名称}::-webkit-scrollbar{

display: none;

}


3、一个元素点击不生效:pointer-events: none;


4、不能长按全选:user-select: none


5、超过显示 “…”

text-overflow: w;

overflow: hidden;

white-space: nowrap;


6.兼容iPhone X:

padding-bottom: constant(safe-area-inset-bottom);

padding-bottom: env(safe-area-inset-bottom);

box-sizing: content-box;


7、react阻止事件冒泡

1). e.stopPropagation();

2).e.nativeEvent.stopImmediatePropagation();

3).document.body.addEventListener('click',

(e) => {

// 通过e.target判断阻止冒泡

if (e.target && e.target.matches('a')) return;

console.log('a');

});