Miscellaneous Important Tips and Tricks Flashcards
Create a clearfix style
.clearfix::after { display: block; content: ‘’; clear: both; }.
Enable text to display ellipses when it overflows
text-overflow: ellipsis;
Prevent text from wrapping:
white-space: nowrap (or normal for wrapping)
Handle whitespace so that spaces are respected or not
Use pre element; alternately, use white-space: pre;
Hide text such that it is still accessible to screen readers
.accessible-hidden { width: 1px, height: 1px; position: absolute !important; clip: rect(1px, 1px, 1px, 1px); }
Create sections of 700px width without wrapper divs (such that background can extend 100% and text only 700px)
padding: 1rem calc(50% - 350px); that’s simplified from (100% - 700px)/2 because 100/2 and 700/2.
create a rectangle with 16/9 aspect ratio using css alone, no width value.
height: 0
padding-top: 56.25%