Centering <a> element with an image inside a div

This question already has an answer here:

  • How to make an image center (vertically & horizontally) inside a bigger div 36 answers

  • 尝试style="text-align:center"

    <div class="col-md-6 logo" style="text-align:center">
    <a class="navbar-brand" href="/index.html">
    <img src="#">
    </a>
    </div>
    

    put your img a class like

    In css

    img.example { margin : auto; }
    

    Problem solved, navbar-brand has float:right by default. so i shanged it to :none; and text align: center;

    链接地址: http://www.djcxy.com/p/75770.html

    上一篇: 将整个页面/非浏览器窗口大小的标题图像div居中

    下一篇: 使用div内的图像居中<a>元素