让文本不可复制
-webkit-user-select: none;
-ms-user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
user-select: none;
复制代码
增加版权信息思路:
1、答案区域监听copy事件,并阻止这个事件的默认行为。
2、获取选中的内容(window.getSelection())加上版权信息,而后设置到剪切板(clipboarddata.setData())。
复制代码
程度垂直居中
1、定位 盒子宽高已知, position: absolute; left: 50%; top: 50%; margin-left:-本身一半宽度; margin-top: -本身一半高度;
2、table-cell布局 父级 display: table-cell; vertical-align: middle; 子级 margin: 0 auto;
3、定位 + transform ; 实用于 子盒子 宽高不定时; (这里是自己罕用办法)
position: relative / absolute;
/*top和left偏移各为50%*/
top: 50%;
left: 50%;
/*translate(-50%,-50%) 偏移本身的宽和高的-50%*/
transform: translate(-50%, -50%); 留神这里启动了3D硬件加速哦 会减少耗电量的 (至于何是3D减速 请看浏览器过程与线程篇)
4、flex 布局
父级:
/*flex 布局*/
display: flex;
/*实现垂直居中*/
align-items: center;
/*实现程度居中*/
justify-content: center;
再加一种程度方向上居中 :margin-left : 50% ; transform: translateX(-50%);
发表回复