COMP 1537 - Week 3 - CSS Layouts
COMP 1537 - Week 3 - CSS Layouts
Also:
Perspective
Large values = less perspective (e.g., 1600px)
Small values = huge distortion (e.g., 60px)
Can use in conjunction with other CSS functions (e.g., rotateY)
Then you bind the animation using selectors and the animation property:
Properties:
@keyframes: specifies the animation
animation: short hand for specifying all animation properties
animation-delay: delay in seconds before animation starts
animation-direction: normal, reverse, alternate, alternate-reverse
animation-duration: how many seconds the animation takes to complete
animation-fill-mode: styles the animation has when not playing
animation-name: the name of the animation
animation-iteration-count: times the animation should play
animation-play-state: running, paused
Much better!
But more work
Fixed layout
Uses absolute values (e.g., pixels) to set the size of containers
E.g., footers/header width/height, column width, logo dimensions
Are specific to a particular resolution (usually width)
Good:
Sometimes requirements for content have to be a specific size
E.g., ads, banners, images, icons
Content easier to manage
Bad:
Can cause horizontal scrolling, which is bad
Layout doesn't resize to browsers
Liquid layout
Using percentages for all containers
Including headers, footers, multi-columns
Stretches and shrinks accordingly
Although in some cases, content can overlap if too big for the container width
Good:
Resize with the browser, don't cause horizontal scrolling
Bad:
Don't solve all layout problems, can cause content to overlap
The Grid (not the English electronic dance group from the 1990s) in CSS:
Allows a container (e.g., body, div, section, etc.) to be divided into rows & columns
Much like a spreadsheet
Has many different ways to specify the rows and columns such as:
Gap between rows & columns
Repeating attributes
Absolute vs relative units of measure (e.g., percentages/viewport w/h vs fractional units)
Labeled areas (e.g., header, footer, main, menu)
For this course, we’ll focus on using the following CSS properties:
grid-template-columns, grid-template-rows – for the container
grid-column, grid-row – for the elements in the container
Using the format:
index / span number_of_spanned columns/rows
E.g., 3 / span 2, which means: start at column/row 2 and span 2 rows – starting at row 2
New to CSS 3
Allow conditions to be made on rendering
Use the @media annotation and specify:
min-width, max-width, min-height, max-height
device-aspect-ratio, min-device-aspect-ratio, max-device-aspect-ratio
only, not, all, and
Fixed layout
Poor choice which assumes one size fits all
Liquid layout
Nice start, lays out compartments on percentage
Adaptive layout
Chooses several templates for known dimensions
Responsive layout
One layout, media queries for ranges, liquid
CSS:
The nav element display set to 'table', width 100%
The nav ul element display set to 'table-row'
The nav ul li elements display set to 'table-cell', text-align 'center'
CSS frameworks attempt to create a lot of classes that you would normally create
yourself
Some examples:
Twitter Bootstrap, Pure, Less
Foundation, Skeleton
Benefits
Can reduce amount of time to create web site templates
Disadvantages
May not solve all your problems, may cause cascade conflicts that are hard to resolve