属性text-align: center;一个好方法来中心使用CSS图像?

img {
    text-align: center;
}

当前回答

使用这个到你的img CSS:

img {
  margin-right: auto;
  margin-left: auto;
}

其他回答

Use:

<dev class="col-sm-8" style="text-align: center;"><img src="{{URL('image/car-trouble-with-clipping-path.jpg')}}" ></dev>

我认为这是在Laravel框架中将图像居中的方法。

我看到了这个帖子,它对我很有用:

img { 位置:绝对的; 上图:0; 底部:0; 左:0; 右:0; 保证金:汽车; } < span style=" font - family:宋体;"位置:相对;最小高度:200 px”> < img src = " https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.png?v=c78bd457575a " > < / div >

(纵横对齐)

如果你正在使用一个带有图像的类,那么下面的步骤就可以了

class {
    display: block;
    margin: 0 auto;
}

如果它只是一个图像在一个特定的类,你想居中对齐,那么下面将做:

class img {
    display: block;
    margin: 0 auto;
}

如果你想将图像设置为背景,我有一个解决方案:

.image {
    background-image: url(yourimage.jpg);
    background-position: center;
}

另一种缩放方法-显示它:

img {
  width: 60%; /* Or required size of image. */
  margin-left: 20% /* Or scale it to move image. */
  margin-right: 20% /* It doesn't matters much if using left and width */
}