CSS Flashcards
CSS Comment Line
/* This is a CSS comment */
Create an id selector
#joeid { }
Create a class selector
.joeclass {
}
Background color
body {
background-color: #FFFFFF;
}
Background image
body {
background-image:url(‘image.jpg’);
}
Background image that repeats horizontally
body{
background-image: url(‘image.jpg’);
background-repeat: repeat-x;
}
Background image that repeats vertically
body {
background-image:url(‘image.jpg’);
background-repeat: repeat-y;
}
Background image in a set position(upper right corner) that doesn’t repeat
body { background-image: url('image.jpg'; background-repeat: no-repeat; background-position: right top; }
background-position properties
left top; left center; left bottom; right top; right center; right bottom; center top; center center; center bottom; %x %y; (top left = 0% 0%, bottom right = 100% 100%) xpos ypos;(top left 0px, 0px) inherit; - Specifies that the setting of the background-position property should be inherited from the parent element.
background-repeat properties
repeat; - repeats horizontally and vertically(default)
repeat-x; - repeats horizontally
repeat-y; - repeats vertically
no-repeat; - does not repeat
inherit; - Specifies the setting of the background-repeat property should be inherited from the parent element.
background-clip properties
border-box - The background is clipped to the border box.
content-box - The background is clipped to the content box.
padding-box - The background is clipped to the padding box.
background-origin properties
border-box - The image is positioned relative to the border box.
content-box - The image is positioned relative to the content box.
padding-box - The image is positioned relative to the padding box.
background-image properties
length - Sets the width and height of the background image. The first value sets the width, the second value sets the height. If only one value is given, the second is set to “auto”.
percentage - Sets the width and height of the background image in percent of the parent element. The first value sets the width, the second value sets the height. If only one value is given, the second is set to “auto”.
cover - Scale the background image to be as large as possible so that the background area is completely covered by the background image. Some parts of the background image may not be in view within the background positioning area.
contain - Scale the image to the largest size such that both its width and its height can fit inside the content area.
What is the CSS Box Model?
Margins –> Border –> Padding –> Content