-1

How do I force my <a> element with an image appear in center of my div? And should I try to center an a element first, so it work out?

<div class="col-md-6 logo">
<a class="navbar-brand" href="/index.html">
<img src="#">
</a>
</div>
t.niese
  • 39,256
  • 9
  • 74
  • 101
  • 1
    Please include a summary of the work you've done so far to solve the problem, and a description of the difficulty you are having solving it. – Sean May 20 '16 at 18:37

3 Answers3

0

try 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>
bob
  • 4,595
  • 2
  • 25
  • 35
0

put your img a class like

In css

img.example { margin : auto; }
  • `margin : auto;` won't have an effect, as long as the `img` has the default value `inline` for `display`. Beside that `margin : auto;` requires a `block` display and the `width` has to be set. – t.niese May 20 '16 at 18:48
0

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