css3 Flashcards
By default anchor tags have a display property of…
inline
What triggers a CSS3 animation?
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 do you set a transition animation to change the color when a roll over occurs?
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.
What property would you use to specify a delay before the animation / transition kicks off?
transition-delay: 3s;
How would you do a shorthand transition?
transition: background-color 1s ease-out .2s;
or
transition: property || duration || timing-function || delay [, …];
How can you make the defining of a transition more efficient when you have multiple properties to define?
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; }
What’s the difference between a pseudo selector/class and a pseudo element?
A pseudo selector allows you to choose an element in a page, a pseudo element actually addresses a sub element of an element.
Which is correct?
a:after
or
a::after?
Technically both - the :: notation isn’t recognised on some older browsers. You can just stick with :
An absolute positioned element is positioned relative too…
….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.
Fixed positioned elements are placed relative too?
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.
Relative positioned elements are positioned…
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.
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.
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.
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?
No - you will have to trigger it separately.
If you have a pseudo element - a.btn:after, how would you target it’s hover state?
a.btn:hover:after {}
If you add padding of 10px to the left - what happens to the overall width of the element?
It becomes 10px wider - so you can use this to make a button slide out.
How can you reduce the amount of text that is used in a transition statemtent?
Use the keyword - if you have a lot of changing elements, and they use the same time…
transition: all .5s;
What is the downside to using the all property?
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
Why shouldn’t you use movement (where the object physically moves out of the way) in a UI?
The user may trigger the event, the element moves out of the way, untriggering it.