CSS Flashcards

(76 cards)

1
Q

p.center {
text-align: center;
color: red;
}

A

< p> elements with class=”center” will be center-aligned

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  • {
    text-align: center;
    color: blue;
    }
A

Universal Selector

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

h1, h2, p {
text-align: center;
color: red;
}

A

grouped selectors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

<link></link>

A

External CSS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

hsla, rbga

A

color hsla(9, 100%, 64%, 0)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

background-image: url(“paper.gif”);

A

background image

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

background-repeat: repeat-x;

A

repeat-x, repeat-y, no-repeat

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

background-attachment: fixed

A

fixed, scroll

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

background: #ffffff url(“img_tree.png”) no-repeat right top;

A

background shorthand

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

border-style: solid;

border-width: 5px;

A

dotted - Defines a dotted border
dashed - Defines a dashed border
solid - Defines a solid border
double - Defines a double border
groove - Defines a 3D grooved border. The effect depends on the border-color value
ridge - Defines a 3D ridged border. The effect depends on the border-color value
inset - Defines a 3D inset border. The effect depends on the border-color value
outset - Defines a 3D outset border. The effect depends on the border-color value
none - Defines no border
hidden - Defines a hidden border

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

border-width: 2px 10px 4px 20px;

A

border-width: 5px;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

border-color: green;

A

border-color: red green blue yellow;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

border: 5px solid red;

A

border-width
border-style (required)
border-color

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

border-left: 6px solid red;

background-color: lightgrey;

A

border-bottom: 6px solid red;

background-color: lightgrey;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

border-left: 6px solid red;

background-color: lightgrey;

A

border-bottom: 6px solid red;

background-color: lightgrey;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

margin: 25px 50px 75px;

A

top margin is 25px
right and left margins are 50px
bottom margin is 75px

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

margin: 25px 50px;

A

top and bottom margins are 25px

right and left margins are 50px

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

max-width

A
The value of the max-width property overrides width
max-height	
max-width	
min-height	
min-width
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q
outline-style
outline-color
outline-width
outline-offset
outline
A

outline: 5px solid yellow;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

text-align

A

center / left/ right/ justify

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

a {
text-decoration: none;
}

A

h1 {
text-decoration: overline;
}

h2 {
text-decoration: line-through;
}

h3 {
text-decoration: underline;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

text-transform

A

p.uppercase {
text-transform: uppercase;
}

p.lowercase {
text-transform: lowercase;
}

p.capitalize {
text-transform: capitalize;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

text-indent

A

p {
text-indent: 50px;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

letter-spacing

A

h2 {
letter-spacing: -3px;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
line-height
p.small { line-height: 0.8; }
26
direction
The direction property is used to change the text direction of an element: p { direction: rtl; }
27
word-spacing
h1 { word-spacing: 10px; }
28
font-family
font-family: "Times New Roman", Times, serif;
29
font-weight
p.normal { font-weight: normal; } p.thick { font-weight: bold; }
30
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
a: hover MUST come after a:link and a:visited a: active MUST come after a:hover
31
list-style-type
ul.a { list-style-type: circle; or none }
32
Table Borders
table, th, td { border: 1px solid black; }
33
border-collapse: collapse;
The border-collapse property sets whether the table borders should be collapsed into a single border:
34
td { height: 50px; vertical-align: bottom; }
The vertical-align property sets the vertical alignment (like top, bottom, or middle) of the content in or
35
tr:hover {background-color: #f5f5f5;}
Use the :hover selector on to highlight table rows on mouse over:
36
tr:nth-child(even) {background-color: #f2f2f2;}
For zebra-striped tables, use the nth-child() selector and add a background-color to all even (or odd) table rows:
37
display: none;
display: none; is commonly used with JavaScript to hide and show elements without deleting and recreating them. Take a look at our last example on this page if you want to know how this can be achieved.
38
visibility:hidden;
visibility:hidden; also hides an element. However, the element will still take up the same space as before. The element will be hidden, but still affect the layout:
39
position
``` static relative fixed absolute sticky ```
40
div.relative { position: relative; left: 30px; border: 3px solid #73AD21; }
An element with position: relative; is positioned relative to its normal position.
41
div.fixed { position: fixed; bottom: 0; right: 0; width: 300px; border: 3px solid #73AD21; }
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.
42
div.absolute { position: absolute; top: 80px; right: 0; width: 200px; height: 100px; border: 3px solid #73AD21; }
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. Note: A "positioned" element is one whose position is anything except static.
43
div.sticky { position: -webkit-sticky; /* Safari */ position: sticky; top: 0; background-color: green; border: 2px solid #4CAF50; }
An element with position: sticky; is positioned based on the user's scroll position. You must also specify at least one of top, right, bottom or left for sticky positioning to work.
44
overflow
visible - Default. The overflow is not clipped. The content renders outside the element's box hidden - The overflow is clipped, and the rest of the content will be invisible scroll - The overflow is clipped, and a scrollbar is added to see the rest of the content auto - Similar to scroll, but it adds scrollbars only when necessary
45
float
left / right / none / inherit
46
clear
The clear property specifies what elements can float beside the cleared element and on which side. none/left/right/both/inherit
47
div p { background-color: yellow; }
Descendant Selector | The following example selects all

elements inside

elements:
48
div > p { background-color: yellow; }
The child selector selects all elements that are the children of a specified element.
49
div + p { background-color: yellow; }
The adjacent sibling selector selects all elements that are the adjacent siblings of a specified element.
50
div ~ p { background-color: yellow; }
The general sibling selector selects all elements that are siblings of a specified element.
51
p:first-child { color: blue; }
The :first-child pseudo-class matches a specified element that is the first child of another element.
52
p:nth-child(2) { background: red; }
Specify a background color for every p element that is the second child of its parent:
53
::first-letter
p::first-letter { color: #ff0000; font-size: xx-large; }
54
list-style-type
``` ul { list-style-type: none; margin: 0; padding: 0; } ```
55
li a { display: block; width: 60px; }
Vertical Navigation Bar
56
:not(p) { background: #ff0000; }
Set a background color for all elements that are not a

element:

57
a[target] { background-color: yellow; }
CSS [attribute] Selector
58
a[target="_blank"] { background-color: yellow; }
CSS [attribute="value"] Selector
59
[title~="flower"] { border: 5px solid yellow; }
The [attribute~="value"] selector is used to select elements with an attribute value containing a specified word.
60
[class|="top"] { background: yellow; }
The [attribute|="value"] selector is used to select elements with the specified attribute starting with the specified value.
61
[class^="top"] { background: yellow; }
The [attribute^="value"] selector is used to select elements whose attribute value begins with a specified value.
62
[class$="test"] { background: yellow; }
The [attribute$="value"] selector is used to select elements whose attribute value ends with a specified value.
63
[class*="te"] { background: yellow; }
The [attribute*="value"] selector is used to select elements whose attribute value contains a specified value.
64
input[type=text]:focus { background-color: lightblue; }
Use the :focus selector to do something with the input field when it gets focus:
65
textarea { resize: none; }
Use the resize property to prevent textareas from being resized (disable the "grabber" in the bottom right corner):
66
border-radius
The border-radius property is actually a shorthand property for the border-top-left-radius, border-top-right-radius, border-bottom-right-radius and border-bottom-left-radius properties.
67
html { background: url(img_man.jpg) no-repeat center fixed; background-size: cover; }
Full Size Background Image
68
``` .hero-image { background: url(img_man.jpg) no-repeat center; background-size: cover; height: 500px; position: relative; } ```
Hero Image
69
background-image: linear-gradient(direction, color-stop1, color-stop2, ...);
CSS Linear Gradients
70
background-image: linear-gradient(direction, color-stop1, color-stop2, ...);
CSS Linear Gradients ``` #grad1 { background-color: red; /* For browsers that do not support gradients */ background-image: linear-gradient(red, yellow); /* Standard syntax (must be last) */ } ```
71
background-image: linear-gradient(angle, color-stop1, color-stop2);
``` #grad { background-image: linear-gradient(-90deg, red, yellow); } ```
72
``` #grad { background-image: radial-gradient(red, yellow, green); } ```
``` #grad { background-image: radial-gradient(red 5%, yellow 15%, green 60%); } ```
73
div { box-shadow: 10px 10px 5px grey; }
horizontal shadow and the vertical shadow / blurr / color
74
``` p.test1 { white-space: nowrap; width: 200px; border: 1px solid #000000; overflow: hidden; text-overflow: clip; text-overflow: ellipsis; } ```
It can be clipped: This is some long text that will not fit in the box or it can be rendered as an ellipsis (...): This is some long text that will
75
What do you want to eat? |
We then assign the for attribute of the element with the value of the id attribute of , like so:
76
We can also provide a step attribute which creates arrows inside the input field to increase or decrease by the value of the step attribute.