Align image next to horizontal menu

1
Hello, I have a small problem, I added a horizontal menu to the site html and wanted to put an image next (right) but it will not, I tried float, align, margin and nothing, I do not know if they can help me to solve the problem, but I thank you all.

HTML code looks like this: In the case "alignright" is just an example

<div id="button">
  <div class="divimg2">
    <ul>
      <li><a href="">Aqui estão a lista do menu</a></li>
      <div class="alignright"><img src "css/images/sidimg.png"></div>
    </ul>
  </div>
</div>

And the CSS looks like this:

.alignright { float:right; }

I think there's a lot missing ( or not ) in CSS to align the image to the right of the menu

    
asked by anonymous 15.03.2016 / 16:55

2 answers

1

Placing the image outside the list works. See if that's how you want it:

.alignright { float:right; }
<div id="button">
    <div class="divimg2">
        <div class="alignright"><img src="css/images/sidimg.png"></div>
        <ul>
            <li><a href="">Aqui estão a lista do menu</a></li>
        </ul>
    </div>
</div>

Or try it here: link

    
15.03.2016 / 17:03
1

Simply assign the value table to display of the menu or include a clearfix within the menu. Here's an example below:

.divimg2 {
  background: #eeeeee;
  width: 400px;
  display: table;
}

.divimg2 ul {
  padding: 0 20px;
}

.divimg2 ul li {
  display: inline-block;
}

.divimg2 img {
  float: right; 
}
<!-- Holder.js (apenas para carregar imagem de exemplo) -->
<script src="https://cdn.rawgit.com/imsky/holder/master/holder.js"></script><!--Menu--><divid="button">
  <div class="divimg2">
    <ul>
      <img data-src="holder.js/60x24?text=Imagem&theme=industrial">
      <li><a href="#">Link 1</a></li>
      <li><a href="#">Link 2</a></li>
      <li><a href="#">Link 3</a></li>
    </ul>
  </div>
</div>

Run the code snippet to see the result and see if that's what you want.

    
15.03.2016 / 17:35