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.