0 choosing between a web and a mobile app
play

0. Choosing between a web and a mobile app (A carryover from last - PowerPoint PPT Presentation

0. Choosing between a web and a mobile app (A carryover from last lecture) Jeff Terrell Layout (UNC COMP 523) 2019-09-11 1 / 48 Options Android (Java or Kotlin) or iOS (Objective C or Swift) React Native (Javascript) Flutter (Dart)


  1. 0. Choosing between a web and a mobile app (A carryover from last lecture) Jeff Terrell Layout (UNC COMP 523) 2019-09-11 1 / 48

  2. Options Android (Java or Kotlin) or iOS (Objective C or Swift) React Native (Javascript) Flutter (Dart) Progressive Web App, or PWA (Javascript) Responsive Web App (Javascript) Jeff Terrell Layout (UNC COMP 523) 2019-09-11 2 / 48

  3. 1. Introduction Lecture overview Jeff Terrell Layout (UNC COMP 523) 2019-09-11 3 / 48

  4. Motivation You will design the UI in Figma, and you’ll need to implement those designs Knowing how to do this using modern tools can save lots of time and cruft Doing this right is very helpful to those with accessibility concerns Jeff Terrell Layout (UNC COMP 523) 2019-09-11 4 / 48

  5. Assumptions You know: That HTML is for describing the content of a web document and represents a tree of elements, each with optional named attributes That CSS is for describing the style of a web document How to interpret CSS selectors, e.g. #wrapper , input[type=text] , or .box Jeff Terrell Layout (UNC COMP 523) 2019-09-11 5 / 48

  6. Caveats We’re dealing with web layout only Some concepts apply very directly to other platforms E.g. React Native only uses Flexbox for layout Jeff Terrell Layout (UNC COMP 523) 2019-09-11 6 / 48

  7. Outline Display types (e.g. block, inline, float) Positioning elements (e.g. relative, absolute, fixed) Flexbox layout Grid layout Responsive design (for mobile-friendly pages) Jeff Terrell Layout (UNC COMP 523) 2019-09-11 7 / 48

  8. 2. Display types Normal flow Jeff Terrell Layout (UNC COMP 523) 2019-09-11 8 / 48

  9. Normal flow Browsers have a default location for each element Depends on window dimensions Called normal flow Two types: block and inline Jeff Terrell Layout (UNC COMP 523) 2019-09-11 9 / 48

  10. Block elements Block elements stack vertically. Examples: paragraphs, headers, lists CSS: display: block; Jeff Terrell Layout (UNC COMP 523) 2019-09-11 10 / 48

  11. Inline elements Inline elements flow left-to-right and wrap to new lines. Examples: words in a paragraph, italic, bold, code, links CSS: display: inline; Jeff Terrell Layout (UNC COMP 523) 2019-09-11 11 / 48

  12. Demo https://comp523.cs.unc.edu/demo.2019-09-11.1. normal-flow.html Jeff Terrell Layout (UNC COMP 523) 2019-09-11 12 / 48

  13. 2. Display types Floating elements Jeff Terrell Layout (UNC COMP 523) 2019-09-11 13 / 48

  14. Floating elements Some elements should not be block or inline Example: an image in a magazine Text or other inline elements flow around it You can float an element to the left or right CSS: float: left; or float: right; Floats don’t contribute directly to size of parents Jeff Terrell Layout (UNC COMP 523) 2019-09-11 14 / 48

  15. Dependence on window dimensions Different window sizes can be surprising Or different amounts of text You can set an element to “clear” the float CSS: clear: left; Can clear left, right, or both Jeff Terrell Layout (UNC COMP 523) 2019-09-11 15 / 48

  16. Demo https: //comp523.cs.unc.edu/demo.2019-09-11.2.floats.html Jeff Terrell Layout (UNC COMP 523) 2019-09-11 16 / 48

  17. 2. Display types Table layout Jeff Terrell Layout (UNC COMP 523) 2019-09-11 17 / 48

  18. Table layout Anything can be displayed as a table CSS properties: display: table; display: table-row; display: table-cell; display: table-caption; caption-side: bottom; Jeff Terrell Layout (UNC COMP 523) 2019-09-11 18 / 48

  19. Example (from MDN) https://developer.mozilla.org/en-US/docs/Learn/CSS/ CSS_layout/Introduction#Table_layout Jeff Terrell Layout (UNC COMP 523) 2019-09-11 19 / 48

  20. 3. Flexbox layout Basic concepts Jeff Terrell Layout (UNC COMP 523) 2019-09-11 20 / 48

  21. Flex container and flex items Flex layout is opt-in CSS: display: flex; Element with flex display property is flex container Direct children are flex items Enables flexible dimensions in one primary dimension Jeff Terrell Layout (UNC COMP 523) 2019-09-11 21 / 48

  22. Flex direction Top-level property on flex container: flex direction CSS: flex-direction: row Valid values: row row-reverse column column-reverse row is default for web (for English); column is default for React Native Jeff Terrell Layout (UNC COMP 523) 2019-09-11 22 / 48

  23. Main axis and cross axis Flex direction determines the main axis The perpendicular direction is the cross axis CSS properties affect either the main or cross axis, so are dependent on the flex direction Jeff Terrell Layout (UNC COMP 523) 2019-09-11 23 / 48

  24. Demo https://comp523.cs.unc.edu/demo.2019-09-11.3. flex-direction.html Jeff Terrell Layout (UNC COMP 523) 2019-09-11 24 / 48

  25. 3. Flexbox layout Aligning and justifying items Jeff Terrell Layout (UNC COMP 523) 2019-09-11 25 / 48

  26. Flex start and end The flex start depends on the writing direction Default: left and top for English, but also depends on flex direction The flex end is the opposite side Jeff Terrell Layout (UNC COMP 523) 2019-09-11 26 / 48

  27. Aligning on the cross axis Use align-items CSS property to align items on the cross axis Common values: flex-start (default) flex-end center stretch baseline Jeff Terrell Layout (UNC COMP 523) 2019-09-11 27 / 48

  28. Justifying on the main axis Use justify-content CSS property to justify items on the main axis Common values: flex-start (default) flex-end center space-between space-around space-evenly Jeff Terrell Layout (UNC COMP 523) 2019-09-11 28 / 48

  29. Demo https://comp523.cs.unc.edu/demo.2019-09-11.4. flex-alignment.html Jeff Terrell Layout (UNC COMP 523) 2019-09-11 29 / 48

  30. 3. Flexbox layout Automatic sizing Jeff Terrell Layout (UNC COMP 523) 2019-09-11 30 / 48

  31. Flex basis Flex basis is how much space to give a flex item along the main axis The item’s final size is also affected by growing and shrinking properties CSS property: flex-basis Valid values: auto (default) a size, like 100px or 2rem Jeff Terrell Layout (UNC COMP 523) 2019-09-11 31 / 48

  32. Flex grow Items may grow to fill the available space Disable this behavior with flex-grow: 0 Enable it with a positive number for flex-grow What does the number mean? Jeff Terrell Layout (UNC COMP 523) 2019-09-11 32 / 48

  33. Available space First, determine initial size of all items from flex-basis values Then, there may be some space left over in the flex container Divide this up fractionally based on flex-grow values of items Example: values of 2, 1, 1 means that the first item gets twice the space of the other two Jeff Terrell Layout (UNC COMP 523) 2019-09-11 33 / 48

  34. Flex shrink Similarly, flex-shrink will shrink items if the main axis overflows Set flex-shrink: 0; to disable shrinking Shrinking takes into account the minimum size of items so may seem broken or inconsistent Jeff Terrell Layout (UNC COMP 523) 2019-09-11 34 / 48

  35. Sizing shorthand Combination of flex-grow , flex-shrink and flex-basis properties CSS: flex: 1 1 auto Special values: initial is equivalent to 0 1 auto auto is equivalent to 1 1 auto none is equivalent to 0 0 auto a number, e.g. 1 is equivalent to 1 1 0 Jeff Terrell Layout (UNC COMP 523) 2019-09-11 35 / 48

  36. Demo https://comp523.cs.unc.edu/demo.2019-09-11.5. flex-sizing.html Jeff Terrell Layout (UNC COMP 523) 2019-09-11 36 / 48

  37. 3. Flexbox layout Interlude Jeff Terrell Layout (UNC COMP 523) 2019-09-11 37 / 48

  38. Flexbox Froggy http://flexboxfroggy.com/ Jeff Terrell Layout (UNC COMP 523) 2019-09-11 38 / 48

  39. 4. Positioning elements Static, relative, absolute, fixed, and sticky Jeff Terrell Layout (UNC COMP 523) 2019-09-11 39 / 48

  40. Static positioning This is the default Just where the browser would place things normally Statically positioned elements are considered unpositioned Jeff Terrell Layout (UNC COMP 523) 2019-09-11 40 / 48

  41. Relative positioning Relative positioning offsets an element from its static position CSS: position: relative; Use top and left CSS properties to specify the offset (Can also/instead specify bottom and right ) These values can be negative Space is still reserved for the element’s static position Demo: https://comp523.cs.unc.edu/demo. 2019-09-11.6.relative-positioning.html Jeff Terrell Layout (UNC COMP 523) 2019-09-11 41 / 48

  42. Absolute positioning Absolute positioning positions an element relative to an ancestor Reference frame is nearest positioned (i.e. non-static) ancestor CSS: position: absolute; and top and left properties Space is not reserved for element’s hypothetical static position Demo: https://comp523.cs.unc.edu/demo. 2019-09-11.7.absolute-positioning.html Jeff Terrell Layout (UNC COMP 523) 2019-09-11 42 / 48

  43. Fixed positioning Fixed position is when an element stays in a single spot on a screen Demo: https://www.davidwalsh.name/demo/ css-fixed-position.php Jeff Terrell Layout (UNC COMP 523) 2019-09-11 43 / 48

  44. Sticky positioning Sticky positioning is a combination of static and fixed positioning Easiest way to describe this is by showing it Demo: http://html5-demos.appspot.com/static/ css/sticky.html Jeff Terrell Layout (UNC COMP 523) 2019-09-11 44 / 48

  45. 5. Responsive web design A quick overview Jeff Terrell Layout (UNC COMP 523) 2019-09-11 45 / 48

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend