I want to implement a list to which new items can be added with buttons. One button at the top of the list to prepend new items, another one at the bottom to append new items.
HTML:
<div>
<div id="list">
<button class="addbtn">prepend item</button>
<ul id="items"></ul>
<button class="addbtn">append item</button>
</div>
</div>
The buttons are only visible when hovering the div containing the list (via css :hover selector).
CSS:
.addbtn {
display: none;
}
#list:hover .addbtn {
display: block;
}
Is there a way (without using JS, only with CSS) to only show the append button, but not the prepend button, when the list is empty? If the list contains at least one item, both buttons should be shown.
JSFiddle: https://jsfiddle.net/uLmzom18/
Edit: here's the JSFiddle with the working solution: https://jsfiddle.net/khu7bahm/