CSS 单行文本超出显示省略号
width: 200px; /* 宽度必须 */
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;样式
布局、省略号、渐变、移动端适配与常用样式片段。 — 共 30 条
共 30 条代码片段
width: 200px; /* 宽度必须 */
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3; /* x 为行数,任意整数 */
overflow: hidden;flex-shrink: 0; /* 比例不缩小 */
flex-grow: 0; /* 即使有剩余空间,比例不放大 */
flex-basis: width; /* 固定空间 */
flex-wrap: wrap; /* 换行,第一行在上方 */img {
width: auto;
height: auto;
max-width: 100%;
max-height: 100%;
}img,
.bg {
image-rendering: -moz-crisp-edges;
image-rendering: -o-crisp-edges;
image-rendering: -webkit-optimize-contrast;
image-rendering: crisp-edges;
-ms-interpolation-mode: nearest-neighbor;
}img,
.bg {
image-rendering: pixelated;
}background: -webkit-linear-gradient(top, #133907, #0a2b00);
background: linear-gradient(270deg, rgba(251, 148, 108, 1) 0%, rgba(227, 32, 49, 1) 100%);background: linear-gradient(to right, red, blue);
-webkit-background-clip: text;
color: transparent;background-image: -webkit-linear-gradient(
left,
#3498db,
#f47920 10%,
#d71345 20%,
#f7acbc 30%,
#ffd400 40%,
#3498db 50%,
#f47920 60%,
#d71345 70%,
#f7acbc 80%,
#ffd400 90%,
#3498db
);
color: transparent;
-webkit-background-clip: text;
background-size: 200% 100%;
-webkit-animation: slide 2s infinite linear;
animation: slide 5s infinite linear;text-indent: -2em;
padding-left: 2em;text-align-last: justify;.wrap {
overflow: hidden;
}
.left {
float: left;
margin-bottom: -10000px;
padding-bottom: 10000px;
}
.right {
float: left;
margin-bottom: -10000px;
padding-bottom: 10000px;
}<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no,viewport-fit=cover">
/* 重点:viewport-fit=cover */padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);::-webkit-scrollbar {
display: none;
}-webkit-touch-callout: none;
-webkit-user-select: none;
user-select: none;cursor: not-allowed;/* focus */
border-color: #50c3f7;
box-shadow: 0 0 8px 0 rgba(80, 195, 247, 0.4);
/* error */
border-color: #f72d51 !important;
box-shadow: 0 0 8px 0 rgba(247, 45, 81, 0.4);input::-webkit-file-upload-button {
/* ... */
}input::-webkit-input-placeholder {
/* ... */
}input {
-webkit-text-fill-color: blue;
}input {
line-height: normal;
}input {
caret-color: red;
}::selection {
background: #f00;
color: #fff;
}a,
button,
input {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
-webkit-tap-highlight-color: transparent;
}input,
textarea {
-webkit-appearance: none;
}-webkit-overflow-scrolling: touch;height: calc(100vh - 0.88rem);@-webkit-keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}@media screen and (max-width: 1600px) {
/* ... */
}
@media screen and (max-width: 1440px) {
/* ... */
}
@media screen and (max-width: 1366px) {
/* ... */
}
@media screen and (max-width: 1280px) {
/* ... */
}
@media screen and (max-width: 1024px) {
/* ... */
}.mask-toast {
position: fixed;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
background: #444;
background: rgba(0, 0, 0, 0.6);
border-radius: 3px;
padding: 15px 40px;
color: #fff;
}