CSS
Posted on September 2, 2022
Tags: javascript
Remember to Ctrl + Shift + R , to hard refresh as chrome will cache your old CSS.
1 Matching Nested Elements >
Using “pre > code.sourceCode” is how to match nested HTML elements.
> code.sourceCode {
pre background-color: #f8f8f8;
}
<pre>
<code class="sourceCode">
<span>
</span></code></pre>
...
2 General matching
/* targets all ul elements */
ul { /* general styles */
}/* targets all li elements within a ul */
ul li { /* general styles */
}/* targets all ul elements within an li element, itself within a ul */
ul li ul { /* overrule general 'outer' styles */
}
3 Wildcard class names ^= *=
Below the CSS selector matches beginning occurrences of “sourceCode…” within a div element when using class^.
When using asterisk, class* it matches the term anywhere.
[class^="sourceCode"]{
divbackground-color: #f8f8f8;
}
[class*="sourceCode"]{
divbackground-color: #f8f8f8;
}
<div class="sourceCode ...">...</div>
<div class="... sourceCode ...">...</div>
4 Selecting by id using #
#logo
#logo > a div
<div id = "logo">
<a> ...</a></div>
5 Inverting color and resizing SVG
note 1rem is size of font
<svg width="3rem" height="3rem" style = "filter:invert(100)">
</svg> ...
5.1 Psuedo Classes match on Behaviors :something
match on behaviors
example
- :link - matches on unclicked links
- :focus - matches on focus
#content a:focus{
border-bottom: 0 px;
}
matches link elements “<a href..>” inside “<..id = content..>” when focused
<div id = content>
<a href=...>somelink</a>
</div>
/* Enable hover interaction if javascript is not available */
@media screen and (min-width: $screen-lg) {
.main-menu .submenu {
uldisplay: none;
}
.main-menu .top-level-entry-container {
ul:hover,
&:focus-within {
&.submenu {
display: block;
}
} }