2

I want the price of coffee to come at the right end of the coffee name i.e 1.80 price should come in line of Americano. Similarly 10.00 price should come in line of Macchiato.

enter image description here

ul {
  list-style: none;
  padding: 5px;
  margin: 0;
}
ul#container {
  width: 18%;
  min-width: 100px;
  max-width: 400px;
  border: 15px solid #886633;
  border-radius: 5px;
  background-color: orange;
  box-shadow: 4px 4px 8px rgba(0, 0, 0, .3);
}
#container li {
  border-bottom: 1px dashed blue;
}
#container > li {
  font-size: 2em;
  border-bottom: 1px solid black;
}
em {
  float: right;
  position: relative;
  bottom: 0px;
}
span {
  width: 100px;
  display: inline-block;
}
<ul id="container">
  <li>DRINK MENU
  <ul>
    <li><span>Latte</span><em>2.79</em>
    </li>
    <li><span>Cappucino</span><em>2.99</em>
    </li>
    <li><span>Cafe Americano</span><em>1.80</em>
    </li>
    <li><span>Espresso</span><em>2.00</em>
    </li>
    <li><span>Carmel Macchiato</span><em>10.00</em>
    </li>
  </ul>
</li>
</ul>

As you can see i am using relative position, but its not working. Can you solve this without absolute position and minimum changes to the code?
Just tell me why is relative position not working.

Varun Jain
  • 81
  • 1
  • 1
  • 13
  • Any reason for not using `position: absolute`? – leo.fcx Jul 27 '15 at 14:12
  • Your HTML is not valid. Your inner `ul` is nested impropertly. Your code renders fine in Chrome, but messed up in jsfiddle. Consider cleaning that up first. – Michael Benjamin Jul 27 '15 at 14:20
  • @leo.fcx absolute position removes the element from the flow, i am making a responsive web design. It needs to adjust according to window size. – Varun Jain Jul 27 '15 at 14:21
  • @VarunJ, your prices would be absolutely positioned within the `
  • ` container, not the viewport. It will be as responsive as the container. Test it.
  • – Michael Benjamin Jul 27 '15 at 14:23
  • @Michael_B it works fine in jsfiddle. Check this [link](http://jsfiddle.net/9kjpnfos/1/) – Varun Jain Jul 27 '15 at 14:25
  • proper way to nest an unordered list: http://stackoverflow.com/questions/5899337/proper-way-to-make-html-nested-list – Michael Benjamin Jul 27 '15 at 14:25
  • your exact code: http://jsfiddle.net/dkohs6m5/ – Michael Benjamin Jul 27 '15 at 14:26
  • @Michael_B it works fine in safari, chrome and firefox. What else i want? – Varun Jain Jul 27 '15 at 14:32
  • If your question has been answered by somebody, then give it a checkmark and an upvote. If not, I'll give it a go. – Michael Benjamin Jul 27 '15 at 14:33
  • Outside of the code, note that "Cappuccino" is spelled incorrectly ;-) – Michael Benjamin Jul 27 '15 at 17:22