0% found this document useful (0 votes)
10 views

Getting More Advanced With Design - Display and Positioning Cheatsheet - Codecademy

The CSS display property determines the type of render block for an element like block, inline, or inline-block. Block elements take up the full width, inline elements take up minimal space, and inline-block allows width/height adjustment. The z-index property specifies layering, with higher values appearing over lower ones. Position can be static, relative, absolute, or fixed; fixed pins an element regardless of scrolling. Float places elements left or right, and clear controls clearing of floats.

Uploaded by

kimato suyaka
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Getting More Advanced With Design - Display and Positioning Cheatsheet - Codecademy

The CSS display property determines the type of render block for an element like block, inline, or inline-block. Block elements take up the full width, inline elements take up minimal space, and inline-block allows width/height adjustment. The z-index property specifies layering, with higher values appearing over lower ones. Position can be static, relative, absolute, or fixed; fixed pins an element regardless of scrolling. Float places elements left or right, and clear controls clearing of floats.

Uploaded by

kimato suyaka
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Cheatsheets / Getting More Advanced with Design

Display and Positioning


CSS display property
The CSS display property determines the type of
render block for an element. The most common values .container1 {
for this property are block , inline , and display: block;
inline-block . }
Block-level elements take up the full width of their
container with line breaks before and after, and can .container2 {
have their height and width manually adjusted. display: inline;
Inline elements take up as little space as possible, ow }
horizontally, and cannot have their width or height
manually adjusted. .container3 {
Inline-block elements can appear next to each other,
display: inline-block;
and can have their width and height manually adjusted.
}

CSS z-index property


The CSS z-index property speci es how far back
or how far forward an element will appear on a web //`element1` will overlap `element2`
page when it overlaps other elements. .element1 {
The z-index property uses integer values, which position: absolute;
can be positive or negative values. The element with z-index: 1;
the highest z-index value will be at the foreground, }
while the element with the lowest z-index value
will be at the back. .element2 {
position: absolute;
z-index: -1;
}

Fixed CSS Positioning


Positioning in CSS provides designers and developers
options for positioning HTML elements on a web page. navbar {
The CSS position can be set to static , postion : fixed;
relative , absolute or fixed . When the }
CSS position has a value of fixed , it is set/pinned to
a speci c spot on a page. The xed element stays the
same regardless of scrolling. The navigation bar is a
great example of an element that is often set to
position:fixed; , enabling the user to scroll
through the web page and still access the navigation
bar.

/
CSS position: absolute
The value absolute for the CSS property
position enables an element to ignore sibling .element {
elements and instead be positioned relative to its position: absolute;
closest parent element that is positioned with }
relative or absolute . The absolute
value removes an element entirely from the document
ow. By using the positioning attributes top , left ,
bottom and right , an element can be
positioned anywhere as expected.

CSS position: relative


The value relative of the CSS position
property enables an element to be positioned relative .element {
to where it would have originally been on a web page. position: relative;
The o set properties can be used to determine the }
actual position of the element relative to its original
position. Without the o set properties, this declaration
will have no e ect on its positioning, it will act as the
default value static of the position property.

CSS float property


The CSS float property determines how far left or
how far right an element should oat within its parent /* The content will float to the left
element. The value left oats an element to the side of the container. */
left side of its container and the value right oats
.left {
an element to the right side of its container. For the float: left;
property float , the width of the container must
}
be speci ed or the element will assume the full width of
its containing element. /* The content will float to the right
side of the container. */
.right {
float: right;
}

/
The CSS clear property
The CSS clear property speci es how an element
should behave when it bumps into another element /*This determines that no other elements
within the same containing element.The clear is within the same containing element are
usually used in combination with elements having the allowed to float on the left side of
CSS float property. This determines on which sides this element.*/
oating elements are allowed to oat. .element {
clear: left;
}

/*This determines that no other elements


within the same containing element are
allowed to float on the right side of
this element.*/
.element {
clear: right;
}

/*This determines that no elements


within the same containing element are
allowed to float on either side of this
element.*/
.element {
clear: both;
}

/*This determines that other elements


within the same containing element are
allowed to float on both side of this
element.*/
.element {
clear: none;
}

You might also like