Css Flashcards
Background-image
background-image: url(‘http://etc.com’);
relative path:
background-image: url(‘images/mountains.jpeg’);
Position
Static and relative positioned elements stay in the normal flow of the document.
Fixed and absolute positioned elements are removed from document flow. When a user scrolls, these elements will stay their specified offset position.
Sticky: keeps an element in the document flow as the user scrolls, but sticks to a specified position as the page is scrolled further.
Display: inline
Inline elements have a box that wraps tightly around their content, only taking up the amount of space necessary to display their content
Not requiring a new line after each element.
Cant be alter in size with Height and width properties
Eg: em, strong, a
Display: block;
Fill entire width of the page by default.
But width property can be set.
Displayed on their own line
No content directly on either side of them
Eg: h1-h6, p, div, footer
display: inline-block;
Can appear next to each other
Can specify dimensions by using width and height properties.
Eg: img
Floated elements must have a width specified. Otherwise, the element will assume the full width of its containing element, and changing float value will not yield any visible results
inline-block is ignored due to the float. If ‘float’ has a value other than ‘none’, the box is floated and ‘display’ is treated as ‘block’
When set to RELATIVE, an element’s position is relative to its default position on the page.
When set to ABSOLUTE, an element’s position is relative to its closest positioned parent element. It can be pinned to any part of the web page, but the element will still move with the rest of the document when the page is scrolled.
When set to FIXED, an element’s position can be pinned to any part of the web page. The element will remain in view no matter what.
When an element’s position is set to ABSOLUTE, all other elements on the page will ignore the element and act like it is not present on the page. The element will be positioned relative to its closest positioned parent element, while offset properties can be used to determine the final position from there.
setting its position property to RELATIVE.
This value allows you to position an element relative to its default static position on the web page.
position: RELATIVE will allow offsets like top to start from the element’s DEFAULT position, not the position of its parent elements.
Which of the following values will position an element in relation to the nearest non-static element?
Absolute
The z-index will be ignored if an element is set to which of the following position values?
Static
Select <a> element with an href attribute value containing “florence”:
a[href*=‘florence’] {
color: lightgreen;
}</a>
Dom: browser’s interpretation of the source code
Documentation object model
Relative file path
- Starting with “/” returns to the root directory and starts there
- Starting with “../” moves one directory backwards and starts there
- Starting with “../../” moves two directories backwards and starts there (and so on…)
- To move forward, just start with the first subdirectory and keep moving forward
img {
display: block; //image will occupy whole line
margin-left: auto;
}
Margin left to set the margin to the left of an element (i.e: image) -> push the image to the right of the webpage
HSL stands for hue (the color itself), saturation (the intensity of the color), and lightness (how light or dark a color is).
Hsla -> alpha or opacity (0-1)
eg:
color: hsla(200, 20%,, 50%, 0.7)
rgb and rgba
@font-face {
font-family: ‘MyWebFont’;
src: url(‘myfont.woff2’) format(‘woff2’),
url(‘myfont.woff’) format(‘woff’);
}
Tooltip: use title attribute
<a>Link anchor text</a>
Link states:
a: link - a normal, unvisited link
a: visited - a link the user has visited
a: hover - a link when the user mouses over it
a: active - a link the moment it is clicked
Box shadow: /* offset-x | offset-y | blur-radius | color */ box-shadow: 10px 5px 5px black;
Flexbox:
div {
display: flex;
}
Div remains a block element. All child elements of the flex container (div) will become inline elements.
Inline-flex:
Creates flex containers that are also inline elements -> div will become an inline elements and their child elements will become inline elements as well.
Below are five commonly used values for the justify-content property:
* flex-start — all items will be positioned in order, starting from the left of the parent container, with no extra space between or before them.
* flex-end — all items will be positioned in order, with the last item starting on the right side of the parent container, with no extra space between or after them.
* center — all items will be positioned in order, in the center of the parent container with no extra space before, between, or after them.
* space-around — items will be positioned with equal space before and after each item, resulting in double the space between elements.
* space-between — items will be positioned with equal space between them, but no extra space before the first or after the last elements.
In the definitions above, “no extra space” means that margins and borders will be respected, but no more space (than is specified in the style rule for the particular element) will be added between elements. The size of each individual flex item is not changed by this property.
Default value: flex grow and flex shrink
flex-grow: 0
flex-shrink: 1
Margins are unaffected by flex-shrink and flex-grow
Below are five commonly used values for the align-items property:
- flex-start — all elements will be positioned at the top of the parent container.
- flex-end — all elements will be positioned at the bottom of the parent container.
- center — the center of all elements will be positioned halfway between the top and bottom of the parent container.
- baseline — the bottom of the content of all items will be aligned with each other.
- stretch — if possible, the items will stretch from top to bottom of the container (this is the default value; elements with a specified height will not stretch; elements with a minimum height or no height specified will stretch).
Flex-grow and flex-shrink will only be employed if the parent container is too small/large or the browser is adjusted.
Align-items: stretch
stretch — if a minimum height or no height is specified, the rows of elements will stretch to fill the parent container from top to bottom (default value).
flex containers have two axes: a main axis and a cross axis. By default, the main axis is horizontal and the cross axis is vertical.
The main axis and cross axis are interchangeable. We can switch them using the flex-direction property. If we add the flex-direction property and give it a value of column, the flex items will be ordered vertically, not horizontally.
The main axis is used to position flex items with the following properties:
justify-content
flex-wrap
flex-grow
flex-shrink
The cross axis is used to position flex items with the following properties:
align-items
align-content
row — elements will be positioned from left to right across the parent element starting from the top left corner (default).
row-reverse — elements will be positioned from right to left across the parent element starting from the top right corner.
column — elements will be positioned from top to bottom of the parent element starting from the top left corner.
column-reverse — elements will be positioned from the bottom to the top of the parent element starting from the bottom left corner.
Flex-flow can take 2 values: flex-direction and flex-wrap eg: .container { flex-flow: column wrap; }
flex can take 3 values: flex-grow, flex-shrink, and flex-basis
if 2 values: flex-grow and flex basis