I created a CSS-only dropdown menu with a simple snippet:
.menu-container {
width: 60px;
float: right;
border: 1px solid #999
}
.menu-container .menu {
display: none;
list-style: none;
position: absolute;
min-width: 80px;
margin: 0;
padding: 0
}
.menu-container:hover .menu,
.menu-container .menu:hover {
display: block
}
.menu-container .menu li {
border: 1px solid #999;
text-align: right
}
<div class="menu-container">
Go to...
<ul class="menu">
<li>
<a href="#">Item #1</a>
</li>
<li>
<a href="#">Item #2</a>
</li>
<li>
<a href="#">Item #3</a>
</li>
</ul>
</div>
The menu is aligned to the right edge of the page. I'm looking to have the list items align to the right of the title "Go to...", similar to the image below:
https://i.sstatic.net/22WIj.png
I want the menu to expand based on the length of the list item text, preventing horizontal scrolling. Any suggestions on how to achieve this? Feel free to suggest changes to the HTML structure if necessary.
Appreciate any assistance!