-
文本超出省略,显示
...
基本要素,有固定的宽度,文本会超出;设置文本超出后不换行;.box{ width:100px; height:30px; background:#000; color:#fff; line-height:30px; } .box p{ white-space:nowrap; // 或 white-space:pre; overflow:hidden; text-overflow:ellipsis; }
-
背景透明,文本不透明。
基本要素,元素的背景色设置使用RGBA
p{ background-color:rgba(255,255,255,0); }
-
图片自适应父元素
可使用max-*
控制宽度、高度。- 铺满整个父元素,图片会被拉伸、变形。
img{ width:100%; height:100%; }
- 等比例缩放、不超出父元素。
img{ max-width:100%; max-height:100%; }
- 如果仅仅一张图做个背景效果。
.img-box{ background-image:url('./*.jpg'); background-size:contain; background-repeat:no-repeat; }
- 铺满整个父元素,图片会被拉伸、变形。
-
禁止掉按钮的事件
cursor:not-allowed;