In session #5 we covered CSS position properties and grouping CSS selectors to select more elements on our webpage. We also did a kahoot quiz summarizing the knowledge from the session
REVIEW: The CSS Box Model
A very important web development model that shows the structure of a webpage
Note: A this stage, you should know what each term in the box model means and can describe how it works in a webpage, just a checkpoint.
CSS Position Properties
CSS Position essentially defines the position of an element on the webpage
Three major types of CSS positions
Relative positioning: An element with position: relative; is positioned relative to its normal position. Setting the top, right, bottom, and left properties of a relatively-positioned element will cause it to be adjusted away from its normal position. Other content won’t adjust to fit into any gap left by element.
Absolute positioning: An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed). However; if an absolute positioned element has no positioned ancestors, it uses the document body, and moves along with page scrolling.
Fixed positioning: An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled. The top, right, bottom, and left properties are used to position the element. A fixed element does not leave a gap in the page where it would normally have been located.
The “float” property
The float property is specifically used for wrapping elements in html around other elements
Most used for wrapping text around images in html
The float property takes in four parameters
left - The element floats to the left of its container
right - The element floats to the right of its container
none - The element does not float (will be displayed just where it occurs in the text). This is default
inherit - The element inherits the float value of its parent
It is important to note that CSS position properties are not required in every webpage, some webpage doesn’t even have it, but CSS position is a great tool if you do want to use it in your webpage
Grouping CSS Selectors
Multiple CSS classes
sometimes we just want one element on our webpage to be in two class groups and inherit the css properties from both groups
in web development, we can give one element multiple css classes. to do it, we just add a space after the first original class, then type your second class. pls see example below for how it works
sometimes in a class, we just want to style certain elements in the class with the same tag-name, and nothing else, we can combine tag tag-name selectors with class selectors
in web development, we do that by typing the tag-name you want to style, this will look for all the elements in your webpage with the same tag-name you typed in; then, without typing a space, complete the rest of the selector with how you would normally select a class (.classname)