CSS之文本溢出隐藏,不定宽高元素垂直水平居中、禁止页面文本复制

1、如何让不固定元素宽高的元素垂直水平居中

1 .center {
2    position: absolute;
3    top: 50%;
4    left: 50%;
5    background-color: #000;
6    width:50%;
7    height: 50%;
8    transform: translateX(-50%) translateY(-50%);
9 }

flex布局写法:

1  .center{
2     display:flex;
3     justify-content:center
4     align-items:center;
5  }

2、禁止div复制功能

1 unselectable="on" onselectstart="return false;"

3、设置文字的溢出隐藏效果

1 td{
2    max-width:125px;
3    overflow:hidden;
4    white-space:nowrap !important;
5    text-overflow:ellipsis;
6    word-break: break-all;
7 }

猜你喜欢

转载自www.cnblogs.com/gerry2019/p/10256770.html