Advanced CSS Flashcards
How do you access attributes in selector?
By adding square brackets [] you can access attributes from CSS.
img[title] - will access all elements img with attribute title
[href=”http://websamuraj.pl”] - all elements with this href
[src$=”.png”] - every element which src attribute ends with “.png”
input[placeholder*=”user”] - input that in placeholder attribute has expression “user”
What is @keyframes syntax for CSS Animations?
@keyframes name { 20% {width: 100%; color: #ee4388;} 50% {width: 10%;} 75% {background-color: orange;} }
then you need to add this
animation to selector to display it on the desired element
What are the animation values that can be set to different animation properties?
animation: is the short format for animation syntax. In reality, it comprises of different attributes:
animation-name: (default: none)
animation-duration: 3s; (default: 0)
animation-delay: 2s (in case we use short-hand syntax this is always the second value that comes seconds as in animation: superAnimacja 10s 2s the delay is 2s, duration 10s)
animation-direction: reverse | alternate | alternate-reverse; (default: normal)
animation-iteration-count: infinite | 100 (default: 1)
animation-fill-mode: both | forwards; (default: none)
animation-timing-function: linear | steps | ease | cubic-bezier (default: ease)
animation-play-state: running | paused (default: running)
What is a flexbox container?
A flex container is the parent object and contains flex items inside of the parent container.
To initiate a flexbox on the parent you need to set the display: flex;
Flex items are primary objects within he Flex container
What is flex direction?
Flex direction is a parent container property.
Direction defines how the flex items will be laid out in the flex container.
The directions are defined by either rows or columns.
(Default direction is a row)
flex-direction: column | row | column-reverse | row-reverse
What is the feature of flex-basis property?
It is a property which refers to flex items.
This property when assigned to an element determines the size of the element. Whether it is width or height, depends on which is the main axis (main axis is set with property flex-direction:
What does justify-content property do?
Justify content is a parent object property, that justifies the contents along the main axis (contrary to align-items which does it along cross axis).
It is applied only if parent container takes more space than it’s children.
justify-content: flex-start; flex-end; center; space-between; space-around; space-evenly;
How do you center elements using flexbox?
You need to apply display: flex to the parent object to make it a flex container
then:
align-items: center;
justify-content: center;
What is the difference between align-content and align-items properties?
The align-items property of flex-box aligns the items inside a flex container along the cross axis just like justify-content does along the main axis.
align-content is for multi line flexible boxes. It has no effect when items are in a single line. It aligns the whole structure according to its value. Here’s an example for align-content: space-around;
What does align-content property do?
It is a property that applies to parent flex container.
It sets the distribution of space between and around content items along a flexbox’s cross-axis or a grid’s block axis.
This property has no effect on single line flex containers (i.e. ones with flex-wrap: nowrap).
It aligns the content of lines in the flex container.
align-content: (default: stretch) | center | flex-end | flex-start | space-beetween | space-around | space-evenly
What is flexbox?
Flexbox is a one-dimensional layout method for laying out items in rows or columns. Items flex to fill additional space and shrink to fit into smaller spaces. It ensures smoothness and scalability of elements, because they fit the space they are provided in the container.
What are the default settings of a flexbox?
flex-direction: row; (elastic elements are set up horizontally one after another)
justify-content: flex-start (from the left side)
flex-basis :auto (elements use up exactly how much space they need (still horizontally because of flex-direction: row), it is not a flexbox container property, but child property)
align-items: stretch; (100% of parent’s height)
flex-wrap: nowrap (the elements are in one line)
flex-shrink: 1 (elements are shirnked, so they do not overflow the container)
What does flex-wrap do?
The flex-wrap CSS property sets whether flex items are forced onto one line or can wrap onto multiple lines. If wrapping is allowed, it sets the direction that lines are stacked.
By default, all elements are shrinked because of flex-shrink: 1 (default property)
flex-wrap: nowrap | wrap | wrap-reverse;
What are the basic flex items properties?
order: (number); (initial value is 0, if the order value is the same, then HTML order is applied. The higher the number, the lower it’s priority)
flex-grow: (number); (works when container is bigger than it’s children. it allows to divide the space between children)
flex-shrink: (shrinks the elements, so they do not overflow the container)
flex-basis: (depending on the flex-direction it decides how high or how wide is element. I overwrites the width and height)
align-self (similar to align-items property for flex container, so it is aligns along the cross axis, but for single element).
How can you apply responsive text content depending on medias applied?
You can use ::before pseudoelement on the h1 tag.
With content: “Welcome to my webpage”.