img响应不居中 [英] img-responsive doesn't center

查看:38
本文介绍了img响应不居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助.
img响应式与此代码无关.

I need some help.
img-responsive doesn't centers with this code.

div.container-main {
    margin-left: auto; 
    margin-right: auto; 
    text-align: center;
}

然后HTML代码就是这个

Then the HTML code is this one

  <div class="container-main">  
  <section class="main">
        <img class="img-responsive" src="img/bio.png" alt="Microscópio Óptico">
  </section>

有什么帮助吗?我已经看过这一个,但是对我没有用.
没有img响应,它的工作效果非常好.
我正在使用Bootstrap.

Any help? I've already seen this one but didn't worked for me.
Without img-responsive it's working excellent.
I'm using Bootstrap.

推荐答案

这是一个非常简单的修复程序.由于Bootstrap的.img响应式已经设置了 display:block ,因此您可以使用 margin:0 auto 将图像居中:

This is a pleasantly easy fix. Because .img-responsive from Bootstrap already sets display: block, you can use margin: 0 auto to center the image:

.img-responsive {
    margin: 0 auto;
}

这篇关于img响应不居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆