Here is the code I'm working with:
ul {
list-style-type: none;
}
ul:not(.sub-menu) {
padding: 0px;
}
ul li {
padding-top: 10px;
}
ul li:first-child:not(.sub-menu) {
margin-bottom: 30px;
}
.submenu {
margin-left: 20px;
}
<ul>
<li>test</li>
<li>test</li>
<li>test</li>
<li>has submenu
<ul class="submenu">
<li>child</li>
<li>child</li>
</ul>
</li>
</ul>
The challenge I am facing is ensuring that only li
elements without a nested ul
have a margin-bottom
of 30px
. Currently, this style affects the nested ul li
elements as well.
I have tried using
ul li:first-child:not(.sub-menu li)
, but it doesn't work. Is there an alternative solution?