Skip to content

Latest commit

 

History

History
557 lines (404 loc) · 11.8 KB

fcc.org

File metadata and controls

557 lines (404 loc) · 11.8 KB

freeCodeCamp

Responsive Web Design

Padding Values

Text

css:

/* Applies to {{c1::all four sides}} */
padding: 1em;

/* Applies to {{c1::vertical, horizontal}} */
padding: 5% 10%;

/* Applies to {{c1::top, horizontal, bottom}} */
padding: 1em 2em 2em;

/* Applies to {{c1::top, right, bottom, left}} */
padding: 5px 1em 0 2em;

Padding

Text

css: An element’s {{c1::Padding}} controls the {{c2::amount of space between its content and border}}

Margin

Text

css: An element’s {{c1::Margin}} controls the {{c2::amount of space between its border and surrounding elements}}

Classes Priority

Text

css: If an element has two classes that style the same property, {{c1::the last one declared in the stylesheet}} has the priority

Class vs Id Priority

Text

css: If an element has an id and a class that style the same property, {{c1::the id}} style has the priority

Inline Priority

Text

css: If an element has an id and an inline style that style the same property, the {{c1::inline}} style has the priority

!important Priority

Text

css: In a stylesheet, override all the possible styles by {{c1::suffixing the property with !important}}

CSS Variables

Text

css: CSS Variables are defined by {{c1::prefixing the property with --}} and are accessed by using {{c1::var()}}

Pseudo-Classes

Text

css: :hover is called a {{c1::Pseudo-Class}}

Relative Positioning

Text

css: With {{c1::relative positioning}} an element can be {{c2::shifted away from its original position}}

Relative Positioning Space Left

Text

css: With {{c1::relative}} positioning the original space the object would take {{c2::is}} preserved

Absolute Positioning

Text

css: With {{c1::absolute positioning}} an element can be {{c2::fixed to an absolute position relative to its parent container}}

Absolute Positioning Space Left

Text

css: With {{c1::absolute}} positioning the original space the object would take {{c2::isn’t}} preserved

Absolute vs Fixed

Text

css: The difference between Absolute and Fixed positioning is that Absolute {{c1::will scroll away from the view}}

z-index

Text

css: {{c1::Change the z-order of overlapping elements}} with {{c2::z-index}}

margin: auto

Text

css: Set {{c1::margin to auto}} to center a block element

linear-gradient()

Text

css: Set {{c1:: background to linear-gradient(DEGREES, COLOR1, COLOR2, ...) }} to create a linear gradient on an element

transform

Text

css: {{c1::Rotate, scale, skew, or translate an element}} with {{c2::transform}}

img’s alt Best Practice

Text

html: best practice: Add an alt attribute to all non-decorative img tags (or set it to “”)

main, header, footer, nav, article, and section Best Practice

Text

html: best practice: Use main, header, footer, nav, article, and section tags

figure and figcaption Best Practice

Text

html: best practice: Use the figure and figcaption tags

Form label “for” and input “name”

Text

html: In the following example “for” is linked to {{c1::id of the input}}. “name” controls the {{c1::name in the name/value pair of the submitted data}}.

<label for="name">Name:</label>
<input type="text" id="name" name="name">

fieldset Best Practice

Text

html: best practice: Wrap radio buttons inside a fieldset tag and add a legend tag

time Best Practice

Text

html: best practice: Use the time tag

Contrast Best Practice

Text

css: Have a contrast of at least 4.5:1 (as recommended by the WCAG)

Media Queries

Text

css: {{c1::Apply different rules to different device sizes}} with {{c2::Media Queries}}

Responsive Images

Text

css: Make images responsive with the following css:

{{c1::

img {
  max-width: 100%;
  height: auto;
}

}}

Responsive Typography

Text

css: Make typography responsive by using one of the following units: {{c1::vw, vh, vmin or vmax}}

flex-direction

Text

css: flex: {{c1::Set the layout (row or column) of flex items}} with {{c2::flex-direction}}

flex-wrap

Text

css: flex: {{c1::Allow items to wrap into a new row or column}} with {{c2::flex-wrap}}

flex-grow and flex-shrink

Text

css: flex: {{c1::Increase or decrease the size of items in a container according to its size}} with {{c2::flex-grow}} or {{c2::flex-shrink}}

flex-basis

Text

css: flex: {{c1::Set the initial size of an item}} with {{c2::flex-basis}}

order

Text

css: flex: grid: {{c1::Set the order of the items}} with {{c2::order}}

grid-gap

Text

css: grid: {{c1::Set a gap between the rows and columns}} with {{c2::grid-gap}}

JavaScript Algorithms and Data Structures

Array Operations

Text

js:

Add an element at the end of an array: {{c1::ARRAY.push()}}

Remove the last element of an array: {{c1::ARRAY.pop()}}

Add an element at the beginning of an array: {{c1::ARRAY.unshift()}}

Remove the first element of an array: {{c1::ARRAY.shift()}}

Concatenate two arrays: {{c1::ARRAY1.concat(ARRAY2)}}

Convert an array to a list of arguments: {{c1::FUNC(…ARRAY)}}

Get the index of an element: {{c1::ARRAY.indexOf(ELEMENT)}}

Access The Property Of An Object

Text

js: Access the property of an object with {{c1::OBJECT.PROPERTY}} or {{c1::OBJECT[PROPERTY]}}

Delete A Property From An Object

Text

js: Remove a property from an object: {{c1::delete OBJECT.PROPERTY}}

Best Practice: Use let or const

Text

js: best practice: Use let or const when possible

Object.freeze()

Text

js: Forbid any changes on an object: {{c1::Object.freeze(OBJECT)}}

Destructuring

Text

js:

const person = { name: "Jody", age: 27 }
const user = { jody: { name: "Jody", age: 27 } }
const array = [1, 2, 3, 4, 5]

Destructure person into two variables, name and age: {{c1:: let { name, age } = person }}

Destructure person into two variables, myName and myAge: {{c1:: let { name: myName, age: myAge } = person }}

Destructure user into two variables name and age: {{c1:: let { jody: { name, age } } = user }}

Destructure array into its first and second values and the rest: {{c1:: let [first, second, ...rest] = array }}

Export Functions

Text

js: Export functions: {{c1:: export { FUNC1, FUNC2 } }}

Import Functions

Text

js: Import functions: {{c1:: import * as myModule from './FILE.js' }}

Check That A Property Exists In An Object

Text

js: Check that a property exists in an object with {{c1::OBJECT.hasOwnProperty(PROPERTY)}} or {{c1::PROPERTY in OBJECT}}

Loop Through The Keys Of An Object

Text

js: Loop through the keys of an object: {{c1:: for (let key in OBJECT) {...} }}