Trying to find a way to automatically adjust spacing between two objects has been a challenge for me. Specifically, I am dealing with menu items and their corresponding prices.
The desired outcome would look something like this:
Burger..........................$9.99
Steak and Potato.........$14.99
Mac and Cheese.........$6.99
The key requirement is that the spacing between each menu item and its price remains consistent. Users should be able to input both the menu item and price, and the space in-between should adjust accordingly.
I have attempted the following solution, but it doesn't seem to work as intended:
.inLine {
display: inline-block;
}
<h1 class='inLine menuItem'> Burger </h1>
<span class='inLine dots'> .....................</span>
<h3 class='inLine price'> $9.99 </h3>
<br>
<h1 class='inLine menuItem'> Steak </h1>
<span class='inLine dots'> .....................</span>
<h3 class='inLine price'> $14.99 </h3>
<h1 class='inLine menuItem'> Mediterranean Chopped Salad </h1>
<span class='inLine dots'> .....................</span>
<h3 class='inLine price'> $14.99 </h3>
The main issue lies in ensuring that the dots occupy the appropriate amount of space regardless of the length of the item name. I've experimented with setting the dots to width: 100%
, but that hasn't solved the problem. Any suggestions?