YouTube Break. https://www.youtube.com/watch?v=lvtfd_rj2he

Similar documents
Layout. Dynamic layout, Swing and general layout strategies

Layout. Dynamic layout Layout design pattern Layout strategies

Layout. Dynamic layout Layout design pattern Layout strategies. 2.6 Layout 2

CSS.

Chapter 3 Style Sheets: CSS

INTRODUCTION TO HTML5! CSS Styles!

Styles, Style Sheets, the Box Model and Liquid Layout

Zen Garden. CSS Zen Garden

Cascading Style Sheets (CSS)

Responsive Web Design. From: Ethan Marcotte - Responsive Web Design 2011

Creating and Building Websites

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

ADDING CSS TO YOUR HTML DOCUMENT. A FEW CSS VALUES (colour, size and the box model)

CSC309 Programming on the Web week 3: css, rwd

CS7026 Media Queries. Different Screen Size Different Design

Media-Specific Styles

Media Types & Media Features

CSS: The Basics CISC 282 September 20, 2014

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

COMS 359: Interactive Media

HTML and CSS COURSE SYLLABUS

CSS: Cascading Style Sheets

CSS Selectors. element selectors. .class selectors. #id selectors

Unveiling the Basics of CSS and how it relates to the DataFlex Web Framework

Block & Inline Elements

Cascading Style Sheets Level 2

The Benefits of CSS. Less work: Change look of the whole site with one edit

HTML Organizing Page Content

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

Adobe Dreamweaver CS6 Digital Classroom

To link to an external stylesheet, the link element is placed within the head of the html page:

Index. alt, 38, 57 class, 86, 88, 101, 107 href, 24, 51, 57 id, 86 88, 98 overview, 37. src, 37, 57. backend, WordPress, 146, 148

CSS 1: Introduction. Chapter 3

HTML + CSS. ScottyLabs WDW. Overview HTML Tags CSS Properties Resources

Assignments (4) Assessment as per Schedule (2)

Introduction to HTML & CSS. Instructor: Beck Johnson Week 2

BIM222 Internet Programming

- HTML is primarily concerned with content, rather than style. - However, tags have presentation properties, for which browsers have default values

CSS Cascading Style Sheets

CSS: formatting webpages

Using CSS for page layout

CSS. Selectors & Measurments. Copyright DevelopIntelligence LLC

Responsive Web Design (RWD)

CSS. Shan-Hung Wu CS, NTHU

Tutorial 4: Creating Special Effects with CSS

Scripting for Multimedia LECTURE 5: INTRODUCING CSS3

Creating and Building Websites

COMP519 Web Programming Lecture 8: Cascading Style Sheets: Part 4 Handouts

What is Widget Layout? Laying Out Components. Resizing a Window. Hierarchical Widget Layout. Interior Design for GUIs

Reading 2.2 Cascading Style Sheets

ID1354 Internet Applications

CSS for Page Layout Robert K. Moniot 1

Deccansoft Software Services

CSS3 Basics. From & CSS Visual Dictionary Learning Curve Books, LLC

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style

Table Basics. The structure of an table

Responsive web design (RWD) CSS3 Media queries. Mobile vs desktop web sites. Web Development 1 CS1115/CS5002

2. Write style rules for how you d like certain elements to look.

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

Session 4. Style Sheets (CSS) Reading & References. A reference containing tables of CSS properties

This tutorial will help both students as well as professionals who want to make their websites or personal blogs more attractive.

Web Design and Development Tutorial 03

CSS: Cascading Style Sheets

Module 2 (VII): CSS [Part 4]

Introduction to WEB PROGRAMMING

CSS. Location, Inheritance & the Cascade. Copyright DevelopIntelligence LLC

Web Information System Design No.4 Put Style to Web Documents. Tatsuya Hagino

CSS: Layout Part 2. clear. CSS for layout and formatting: clear

AGENDA :: MULTIMEDIA TOOLS :: (1382) :: CLASS NOTES


Advanced Dreamweaver CS6

CSS Cascading Style Sheets

Cascade Stylesheets (CSS)

Cascading Style Sheets

HTML-5.com itemscopehttp://data-vocabulary.org/breadcrumb<span itemprop="title">html 5</span> itemscopehttp://data-vocabulary.

Website Development with HTML5, CSS and Bootstrap

WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5

Page Layout. 4.1 Styling Page Sections 4.2 Introduction to Layout 4.3 Floating Elements 4.4 Sizing and Positioning

HTML Organizing Page Content

Client-Side Web Technologies. CSS Part I

<body bgcolor=" " fgcolor=" " link=" " vlink=" " alink=" "> These body attributes have now been deprecated, and should not be used in XHTML.

Using Dreamweaver CC. Logo. 4 Creating a Template. Page Heading. Page content in this area. About Us Gallery Ordering Contact Us Links

Laying Out Components. What is Widget Layout?

Class 3 Page 1. Using DW tools to learn CSS. Intro to Web Design using Dreamweaver (VBUS 010) Instructor: Robert Lee

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) More on Relative Linking. Learning Objectives (2 of 2)

1/6/ :28 AM Approved New Course (First Version) CS 50A Course Outline as of Fall 2014

Cascading Style Sheet Quick Reference

Chapter 7 BMIS335 Web Design & Development

Cascading Style Sheets CSCI 311

COMS 359: Interactive Media

INTRODUCTION TO CSS. Mohammad Jawad Kadhim

Resizing a Window. COSC 3461: Module 5B. What is Widget Layout? Size State Transitions. What is Widget Layout? Hierarchical Widget Layout.

2005 WebGUI Users Conference

ITNP43: HTML Lecture 5

Page Layout Using Tables

CSS مفاهیم ساختار و اصول استفاده و به کارگیری

Using Dreamweaver CC. 6 Styles in Websites. Exercise 1 Linked Styles vs Embedded Styles

Introduction to using HTML to design webpages

Transcription:

Layout Jeff Avery

YouTube Break https://www.youtube.com/watch?v=lvtfd_rj2he

Positioning Visual Components Previously, we learned about event handling and model-view-control architecture. Next, we need to have an efficient way to layout (or position) the visual components associated with the views.

Overview Motivation Layout Manager CSS and Responsive Design

Overview Motivation Layout Manager CSS and Responsive Design

Two Interface Layout Tasks (1) Designing a spatial layout of widgets in a container (2) Adjusting that spatial layout when the container is resized Both can be done by hand (e.g., graphic design) or automatically (i.e., with algorithms).

Dynamic Layout If a window is resized, we want to 1. maximize use of available space for displaying widget. but we want to do this such that 2. maintain consistency with spatial layout 3. preserve visual quality of spatial layout Need to dynamically modify the layout: re-allocate space for widgets adjust location and size of widgets perhaps even change visibility, look and/or feel of widgets

Responsive Design Changing layout to adapt / respond to different devices e.g., same webpage with layouts for desktop, tablet, smartphone Often goes beyond spatial layout to swapping widgets Dynamic layout a special case of adaptive / responsive layout http://www.amazium.co.uk/

Widget Size and Positions To make a layout dynamic, widgets need to be flexible x,y position may be changed width and height may be changed However, these changes can be constrained Widgets give the layout algorithm constraints on position e.g. must be anchored on the left side of the window Widgets give the layout algorithm a range of sizes: minimum size < preferred size < maximum size But Button Button Button

Overview Motivation Layout Manager CSS and Responsive Design

Layout Managers A LayoutManager provides layout algorithm to size and position child widgets. The Java Swing Package, for example, provides a LayoutManager. Widgets can use different LayoutManager s strategies container.setlayout(new GridLayout(2,3)); This is especially useful for container widgets like JPanel.

Layout Manager Attributes Does it respect a widget's preferred/min/max size? Always ignored? Always respected, even if parts of a widget extend off the edge? Respected in some dimensions but not others? How does it handle extra space? Add extra space around widgets? Give it equally to all widgets? Give it unequally to widgets? Do widgets require additional constraints? Where in the layout manager? Alignment? Share of additional space?

Layout Design Patterns Layout in Java makes use of two design patterns: Composite Pattern Strategy Pattern

Composite Design Pattern The composite pattern describes that a group of objects are to be treated in the same way as a single instance of an object. The intent of a composite is to "compose" objects into tree structures to represent part-whole hierarchies. Implementing the composite pattern lets clients treat individual objects and compositions uniformly.

Composite Design Pattern in Swing JFrame JLabel JButton JSlider JMenuBar JMenu JPanel JMenuItem JRadioButton

Strategy Design Pattern The idea is to factor out an algorithm into separate object, thereby allowing a client to dynamically switch between algorithms. e.g. Java Comparator strategy for a Collection context e.g. Switching layouts at runtime

General Layout Strategies Fixed layout Intrinsic size Variable intrinsic size Struts and springs

Fixed Layout Widgets have a fixed size, fixed position In Java, achieved by setting LayoutManager to null Where/when is this practical? How can it break down even when windows aren t resized?

Intrinsic Size Layout Query each item for its preferred size Grow the widget to perfectly contain each item A bottom-up approach where toplevel widget s size is completely dependent on its contained widgets Example LayoutManagers in Java that use this strategy - BoxLayout, FlowLayout Can you think of other examples of use in interface design?

Variable Intrinsic Size Layout Layout determined in bottom-up and top-down phases: 1. Get each widgets preferred size. 2. Set the container bounds based on widgets and its own preference Example LayoutManagers in Java - GridBagLayout, BorderLayout

Struts and Spring Layout Layout specified by marking aspects of widgets that are fixed vs. those that can stretch Strut is a fixed space (width/height) Specifies invariant relationships in a layout Spring stretches to fill space (or expand widget size) Specifies variable relationships Springs are called glue in Java Can add more general constraints too e.g. widget must be EAST of another widget Example LayoutManagers in Java SpringLayout, BoxLayout (pretty restricted form)

Overview Motivation Layout Manager CSS and Responsive Design

CSS: Cascading Style Sheets CSS splits presentation from content, and defines how HTML should be displayed. Replaces early HTML elements (e.g. font, color) CSS stylesheets can be placed in a file and imported. Stylesheet consists of a series of declarations.

CSS: Cascading Style Sheets Stylesheets chain a series of declarations together: CSS allows you to unexpected things like normalize the visual appearance across different browsers (e.g., by using CSS reset (http://www.cssreset.com) layout a grid without using <table>

CSS: Advantages Consistency consistent layout and look across pages and within pages changes can be applied consistently across pages Minimize network traffic (cache the CSS file) Reduce the amount of code by facilitating style reuse Separation of concerns between styling and content

Pre-built Stylesheets

The Cascade A single HTML document may have many stylesheets. There may be in-line styles. The browser has pre-defined styles. The user can define styles. For a given element, which one takes precedence? How are missing values filled in?

The Cascade (from W3C) 1. Find all the declarations that match the element. If no declarations apply, exit algorithm. 2. Sort declarations by explicit weight: declarations marked! important carry more weight than unmarked declarations. 3. Sort by origin: the author s stylesheets override the reader s style sheet which overrides the web browser s default values. 4. Sort by specificity of selector: more specific selectors will override more general ones. 5. Sort by order specified: if two rules have the same weight, the latter specified wins.

CSS Concepts selectors (demo_2) floats (demo_3, demo_4, demo_5) box model (demo_6) @media (demo_7) block vs inline (demo_8) positioning (demo_9) pseudo-selector (demo_10)

CSS Concepts selectors (demo_2) floats (demo_3, demo_4, demo_5) box model (demo_6) @media (demo_7) block vs inline (demo_8) positioning (demo_9) pseudo-selector (demo_10)

Selectors: Rule Structure Selector p { } Property Declaration block Value padding-left: 20px; color: red;

Selectors <head> <meta charset="utf-8"/> <title> </title> <link href="css/some-stylesheet.css rel="stylesheet"/> <script src="scripts/some-script.js > </script> </head>

Selectors What HTML CSS Universal * { } Type <p> p { } Descendent <ul> <li> <em> ul em { } Child <p> <em> p > em { } Pseudoselectors <tr><td> </td><td> td:active { } a:hover Class <div class= floatleft big > div.floatleft { } or.big{ } Id <img id= cicero > #cicero { }

Selectors: Values Colors #RRGGBB (e.g., #FFFF00 for yellow) rgb(rr.rr%, gg.gg%, bb.bb%) black, yellow silver, gray maroon, purple and about 150 others Numbers Percentage: 50% Absolute:.5in, 1cm, 10mm, 50pt, 50px Relative: 1.2em

CSS Concepts selectors (demo_2) floats (demo_3, demo_4, demo_5) box model (demo_6) @media (demo_7) block vs inline (demo_8) positioning (demo_9) pseudo-selector (demo_10)

Floats By default, HTML is governed by the normal flow in which each element stacks one of top of each other vertically. Floats allow the elements to break this pattern. According to WC3: A float is a box that is shifted to the left or right on the current line. The most interesting characteristics of a float (or floating box ) is that content may flow along its side (or be prohibited from doing so by the clear property). Content flows down the right side of a left-floated box and down the left side of a right-floated box.

CSS Concepts selectors (demo_2) floats (demo_3, demo_4, demo_5) box model (demo_6) @media (demo_7) block vs inline (demo_8) positioning (demo_9) pseudo-selector (demo_10)

Box Model padding margin border height width content All HTML elements have a box model, which includes content, padding, margin and border. Margins can have negative lengths Padding and borders default to 0 and none.

CSS Concepts selectors (demo_2) floats (demo_3, demo_4, demo_5) box model (demo_6) @media (demo_7) block vs inline (demo_8) positioning (demo_9) pseudo-selector (demo_10)

Responsive Design Rather than tailoring disconnected designs to each of an everincreasing number of web devices, we can treat them as facets of the same experience. We can design for an optimal viewing experience, but embed standards-based technologies into our designs to make them not only more flexible, but more adaptive to the media that renders them. In short, we need to practice responsive web design. - Ethan Marcotte, A List Apart

@media @media screen and (min-width: 450px) and (min-device-width: 450px) {.cell { width: 50%; color: blue; } h1 { color: blue; font-style: italic; } }

Recognized media types type all braille embossed handheld print projection screen speech tty tv description suitable for all devices intended for braille tactile feedback devices. intended for paged braille printers intended for handheld devices intended for paged material and for documents viewed intended on for screen projected in print presentations preview mode. intended primarily for color computer screens intended for speech synthesizers intended fixed-pitch character grid. intended for television-type devices.

Debugging Responsive Design

CSS Concepts selectors (demo_2) floats (demo_3, demo_4, demo_5) box model (demo_6) @media (demo_7) block vs inline (demo_8) positioning (demo_9) pseudo-selector (demo_10)

Block versus Inline Block creates a break before and after placed below previous elements on the next line examples: p, div, form, header, nav, ul, li, h1, table Inline no break before and after displayed inside the current block on the same line examples: a, span, b, em, i, strong, img

CSS Concepts selectors (demo_2) floats (demo_3, demo_4, demo_5) box model (demo_6) @media (demo_7) block vs inline (demo_8) positioning (demo_9) pseudo-selector (demo_10)

Positioning Static the default position for any element on a Web page, displayed based on its location inside the normal flow of the HTML document. Absolute the element is taken out of the normal flow of the document (i.e., it won't affect how the elements before it or after it in the HTML are positioned) and placed in an exact location on the page. e.g., footer Relative: the position is based on offset from the current position of the element on the page, instead of the browser s viewport.

CSS Concepts selectors (demo_2) floats (demo_3, demo_4, demo_5) box model (demo_6) @media (demo_7) block vs inline (demo_8) positioning (demo_9) pseudo-selector (demo_10)

Welcome to the Wonderful World of CSS!