给图片fixed定位在页面水平居中 .img-item{ position: fixed; margin: 0 auto; top: 10%; left: 0; bottom: 0; right: 0; z-index: 10 } 设置遮罩层 .img-item::before{ content: " "; width: 100%; height: 100%; position: fixed; background: rgba(0,0,0,.3); top: 0; left: 0; }