- This topic is empty.
-
AuthorPosts
-
January 26, 2016 at 9:34 am #237325
grimski
ParticipantI think everyone comes across this issue once and a while, it’s been a while since I’ve investigated it so I thought I’d asked the question and see if anyone had any alternatives to the solution I’d normally go for.
I basically have a list, which can have 2 states. The 1st is a straightforward list with only list-items (containing anchors) as children. The 2nd contains a nested list. You can see them both in the following CodePen:
http://codepen.io/moy/pen/EPELbe
The problem is as the parent
li
essentially become headings, I want to increase thefont-size
, which I’ve done. But then when the list doesn’t contain nestedul
‘s, I’d want the text to appear smaller again.Is there anyway to target this without adding a class of
has-child
ornav__item--has-child
(to follow my BEM convention)?The good thing is, when the list contains a further level of nested
ul
‘s, the parentli
won’t contain an anchor, so I could style the high-level items likeli {font-size: 20px}
and the anchora {font-size: 16px}
?That seems a bit hacky to me and could bring up consistancy issues with font size/alignment and line-height. What do people think, maybe the class is the safe fool-proof choice?
January 26, 2016 at 10:08 am #237330Paulie_D
MemberUntil CSS Level 4 comes long there is no way of changing the styles of a parent based on a child.
So, a class would be the way to go
January 27, 2016 at 2:36 am #237356grimski
ParticipantThanks, as expected but it’s good to return to these things from time to time incase progress has been made!
I’ve updated the CodePen: http://codepen.io/moy/pen/EPELbe
I have a couple of questions, not related to the font-size but to avoid a new thread I’ll ask here:
- Regarding BEM, i’ve used the class of
keyword-index__item--has-child
is that ok? Or is it acceptable to just usehas-child
? I seem to come across different levels of strictness! -
Is about
column-count
. It seems a bit hit and miss? For example if you look at the updated CodePen, why does the first list not span into 5 columns as is declared – it’s how the second list is displayed?
I’ve also noticed margins can run into the next column. For example if the last item in a column is the end of a (parent) list-item, the
margin-bottom
can appear at the top of the next column, pushing everything down? - Regarding BEM, i’ve used the class of
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.