css3 Flashcards

1
Q

By default anchor tags have a display property of…

A

inline

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

What triggers a CSS3 animation?

A

When a property is changed on a CSS3 object, if it has a transition set - it will trigger the animation. This can occur even from pseudo selectors, such as hover.

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

How do you set a transition animation to change the color when a roll over occurs?

A

a.btn {
display: inline-block;
border: 1px solid rgba(255,255,255,.5);
padding: 5px 20px 5px 10px;
text-decoration: none;
letter-spacing: 2px;
margin: 0px 0px 10px 0px;
color: #fff;
width: 200px;

    transition-property: background-color;
    transition-duration: 1s; }

a.btn:hover {
background-color: rgba(0, 0, 0, 0.4);
}

// NOTE: The hover pseudo selector is what triggers the animation. That property (background-color) matches the proeprty that is being watched in the a.btn selector.

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

What property would you use to specify a delay before the animation / transition kicks off?

A

transition-delay: 3s;

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

How would you do a shorthand transition?

A

transition: background-color 1s ease-out .2s;
or
transition: property || duration || timing-function || delay [, …];

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

How can you make the defining of a transition more efficient when you have multiple properties to define?

A

If you are changing multiple border properties for instance, just define ‘border’ on the transition.

transition: background-color .5s,
border .5s;

a.btn:hover {
       background-color: rgba(0, 0, 0, 0.4);
       border-color: #fff;
       border-left-width: 15px; 
 }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What’s the difference between a pseudo selector/class and a pseudo element?

A

A pseudo selector allows you to choose an element in a page, a pseudo element actually addresses a sub element of an element.

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

Which is correct?

a:after
or
a::after?

A

Technically both - the :: notation isn’t recognised on some older browsers. You can just stick with :

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

An absolute positioned element is positioned relative too…

A

….the first parent element that has a position other than static applied to it. If no parent element up the chain meets that condition the absolutely positioned element is positioned relative to the document window.

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

Fixed positioned elements are placed relative too?

A

First the fixed positioned element is always positioned relative to the browser window and take the now familiar top, right, bottom, and left properties.. It’s the positioning rebel that ignores it’s parents.

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

Relative positioned elements are positioned…

A

Relatively positioned elements are positioned based on the same top, right, bottom, and left properties, but are simply shifted from where they would normally sit. In a sense adding relative positioning is similar to adding a margin with one very important difference. The elements around a relatively positioned element act as though that shift didn’t exist. They ignore it.

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

Do absolute positioned elements have to have a parent element that is set “position: relative” in order to be positioned relative to it’s parent.

A

Technically no - it’s not tthat the parent is positioned relative, it’s that it has a position at all. Remember, elements with absolute position will be positioned relative to the first parent up the chain that has a position other than static.

It doesn’t matter if it is relative - it just happens that a relative position is convenient because it doesn’t take the element out of the document flow.

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

If you have a pseudo element that has it’s own transition - and it is within an element that also has a transition on it - will the pseudo element transition be triggered when the parents transition is triggered?

A

No - you will have to trigger it separately.

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

If you have a pseudo element - a.btn:after, how would you target it’s hover state?

A

a.btn:hover:after {}

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

If you add padding of 10px to the left - what happens to the overall width of the element?

A

It becomes 10px wider - so you can use this to make a button slide out.

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

How can you reduce the amount of text that is used in a transition statemtent?

A

Use the keyword - if you have a lot of changing elements, and they use the same time…

transition: all .5s;

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

What is the downside to using the all property?

A

In something like a rollover, you may change a lot of properties that you don’t actually want to animate. By using all - any animatable property will be animated. IF you have a mix of stuff, you will need to specify each element to change

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

Why shouldn’t you use movement (where the object physically moves out of the way) in a UI?

A

The user may trigger the event, the element moves out of the way, untriggering it.

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

How do you add a text shadow to text?

A

text-shadow: 0px 5px 2px rgb(255,255,255, 0.5);

x offset
y offset
blur
colour

20
Q

If you are using a transition to change the line height, how can you make sure the containing box doesn’t increase in size?

A

Set the lineheight - as you scale the text size, the line-height will grow with it. If you fix it it size, it will not change unless you animate it.

21
Q

What does the clip property do?

A

It allows us to mask out an image in CSS only

22
Q

If you set the clip property to:

clip: rect( 0px, 75px, 75px, 0px);

on an image that is 75px in size - what happens?

A

Nothing - the values will set a mask that is aligned with it’s outside edge (since both are 75px). This will allow us to resize the image, in an animation, but keep the outside edges clipped.

NOTE: The dimensions are based on top, right, bottom, left - just like margin/padding. The origin of the image is the top left corner, so setting your right value to 75px, is setting a clipping line on the right side, 75px from the origin.

23
Q

How would you crop 10px on all sides of an image that is 75px on all sides?

A

clip: rect(10px, 65px, 65px, 10px);

24
Q

How can you pause an animation?

A
.paused{
    -webkit-animation-play-state:paused;
    -moz-animation-play-state:paused;
    -o-animation-play-state:paused; 
    animation-play-state:paused;
}

By simply adding this class.

25
Q

Transition declarations are always added to…

A

the initial state

26
Q

What are the trigger states?

A
\:hover
\:focus,
\:active
\:target
\:checked (form elements)
\:disabled
27
Q

What CSS rule can be used to scale a window?

A

@viewport {
zoom: 1.0;
width: device-width;
}

28
Q

What CSS media query can be used to load different stuff based on screen dimenions?

A

@media (min-width: 500px) and (max-width: 600px) {

}

29
Q

How do you use javascript to change the style of say the background-color of an element?

A

element.style.backgroundColor = ‘red’;

30
Q

What is one way to resize a CSS object without resorting to changing the width and height?

A

On the hover, you can just use:

transform: scale(1.2);

(NOTE: You still need a transition effect on the target element)

transition: transform 2s;

31
Q

When you are specifying time, on a transition - what do the two numbers do?

A

transition: transform 2s 0.5s;

The first number is the duration, the second is the delay

32
Q

If you want to add a rotation transform, what’s one thing that you must remember to do?

A

In the containing div - give it a perspective value.

perspective: 1000px;

33
Q

How would you rotate an object around the x axis?

A

transform: rotateX(30deg);

34
Q

How would you define a character to slide from position to another using keyframes??

A

Use the @keyframe keyword

@keyframes slide {
from { transform: translateX(0); }
to { transform: translateX(900px); }
}

NOTE: The target of this keyframe will need to reference it.

.robot {
animation-name: slide;
animation-duration: 2s;
}

35
Q

Other than using “from and to” to define the keyframes, what is the other method?

A

percentages.

36
Q

What do you use the cubic-bezier function for?

A

It’s a way of specifying the animation-timing-function. This would normally be were you put ‘ease, ease-in’ etc. But you can be more precise.

animation-timing-function: cubic-bezier(.5,.69,.72,1.17)

37
Q

You can combine two sets of animations on one css object - but there is a catch, what is it?

A

They must be different sets of properties. You can’t combine to sets of transforms for instance, once would transform, one can be colour / opacity.

38
Q

If you have a transform of “rotate”, what is it’s unit of measure?

A

transform: rotate(0turn)

39
Q

How do you make it so that your animation doesn’t start immediately (say if you want to trigger it on a hover)?

A

set the
animation-play-state: paused

attribute

40
Q

HOw do you trigger your paused animatoin to play?

A

By triggering the state:

animation-play-state: running

This can be done in an :hover for instance.

41
Q

What is the process for playing a sprite animation in CSS?

A

You setup a div, load the image in the background. The div should be the width / height of a single frame. THe position is 0 0 no-repeat. and the background will be transparent.

You animate this using the same animation timing functions as you do for transforms / transitions.

42
Q

How would you set your keyframes to play a sprite animation in a div?

A
// From the div - set the animation	
animation: walker 2s steps(10) infinite;
}

@keyframes walker {
0% { background-position: 0 0; }
100% { background-position: 0 -5000px;}
}

NOTE: The keyframes aren’t moving the div itself, they are changing the background position. It’s the timing function (steps) that’s important - as it’s performing the flip book effect. So the -5000 / 10 (value in steps) - should give the coordinates to each frame in the file.

43
Q

When is the :active selector triggered?

A

usually only for a short duration - i.e. when clicking on a link , it indicates that something has become active.

44
Q

Describe the box model?

A

Every element on the page in CSS can be described as a box. The box model is made up of the content width, height, the border, the padding and the margin.

The margin is unique in that it doesn’t actually contribute to the width of the box, but does affects it’s relationship with objects around it. So it’s still considered a part of the box model.

Browsers have handled the model differently however, over the years.

Some browsers used the w3c standard, width gave the content width.

Some used the IE traditional method. Width included up to the border edges (including padding).

The box-sizing attribute allows you to change between models:

box-sizing: border-box
box-sizing: content-box

45
Q

What’s the difference between inline, inline-block, and block?

A

The way they flow things around them, and the way they can be positioned.

So an inline element is like text, it can sit in amongst text, and does not obey height commands, and padding commands to the top and bottom don’t affect the layout.

They can not have their height / width set.

inline-block on the other hand, does obey width and height, and can have padding set. But it doesn’t take up the full line.

Block level elements on the other hand, by default take up the full line - and can have width / height etc set. You can control how elements flow around a block level element using the float attribute.