- This topic is empty.
-
AuthorPosts
-
April 24, 2012 at 11:50 am #37765nate22Member
I have a horizontal list that looks like this:
link one | link two | link three | link four |
I want it to look like this instead (no right border on link 4):
link one | link two | link three | link four
…how can I do this?
EDIT: can NOT be done reliably in a autonav because with the variable widths of the navigation (driven by the anchor text length), the last item could be the end of row one or it maybe at the start of row two, etc.
April 24, 2012 at 11:53 am #101706Paulie_DMemberThere are a number of ways to do it depending on your particular situation.
Apply a special class (perhaps ‘last’) to that list item which removes the border.
Another is to use ‘last-of-type’.
April 24, 2012 at 12:06 pm #101707nate22MemberIt’s not “last,” but it might be “last-of-type” (I’m not sure what that is).
The actual UL goes to multiple lines because it is auto-generated. Is there a way to target the end of each line, not just the last element of the UL?
April 24, 2012 at 12:13 pm #101708Paulie_DMemberWe’d need to see your code, a link would be better, to be able to offer specific solutions.
April 24, 2012 at 12:18 pm #101709nate22MemberEDIT: can NOT be done reliably in a autonav because with the variable widths of the navigation (driven by the anchor text length), the last item could be the end of row one or it maybe at the start of row two, etc.
April 24, 2012 at 12:47 pm #101710nate22Memberhave I frightened you away with my sloppy code?
April 24, 2012 at 1:02 pm #101711Taufik NurrohmanParticipantTry something like this:
nav li {
border-right:1px solid black;
}
nav li:last-child {
border-right:none;
}April 24, 2012 at 1:16 pm #101712AnonymousInactive@Hompimpa That is close, but older versions of IE do not support last child.
The workaround is very simple though! Seeing as first child IS supported in IE, simply do the reverse.
nav li {
border-left: 1px solid black;
}
nav li:first-child {
border-left: 0;
}
April 24, 2012 at 1:36 pm #101716nate22MemberThanks, Hompimpa, but that doesn’t work because each link is within a separate LI. So the last-child of the LI is also the first.
IE:
< UL>
< LI >< a >link< /a >< /LI >
< LI >< a >link< /a >< /LI >
< LI >< a >link< /a >< /LI >
< /UL >EDIT: can NOT be done reliably in a autonav because with the variable widths of the navigation (driven by the anchor text length), the last item could be the end of row one or it maybe at the start of row two, etc.
April 24, 2012 at 1:36 pm #101717Taufik NurrohmanParticipant@TheDark12 Hah! I don’t know about that :p
How about this:
nav li a {
border-left: 1px solid black;
}
nav li:first-child a {
border-left: 0;
}April 24, 2012 at 1:45 pm #101719nate22MemberGood thinking, Hopimpa… but, then, will I have the same problem on lines 2 and 3 on the left side rather than the right side? It seems like this new code would just move the | to the left side at the beginning of new lines (except for the first line, of course).
EDIT: can NOT be done reliably in a autonav because with the variable widths of the navigation (driven by the anchor text length), the last item could be the end of row one or it maybe at the start of row two, etc.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.