I have an issue when selecting the first ul
and its first li
but it affects the first li
of the second ul>li
too.
My attempt:
#main-nav ul:first-child li:first-child{
border-radius:5px 0px 5px 0px;
}
The corresponding html:
<nav id="main-nav">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Photos</a>
<ul>
<li><a href="#">Gallery 1</a></li>
<li><a href="#">Gallery 2</a></li>
</ul>
</li>
<li><a href="#">About</a></li>
<li><a href="#">Contacts</a></li>
</ul>
<div style="clear:both;"></div>
</nav>
I think what you are after is:
#main-nav ul:first-child > li:first-child {
border-radius:5px 0px 5px 0px;
}
This will only select the first li
of the first ul
as >
selects only child elements of the element preceding it.
As Paulie_D suggests, #main-nav > ul > li:first-child
is a bit more concise and will also work as long as there is just the one child ul
in #main-nav
.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다