Showing posts with label CSS. Show all posts
Showing posts with label CSS. Show all posts

Thursday, October 30, 2014

Next Web

I recently watched Eric Bidelman's talk from Google I/O 2013 on Web Components.  This talk was on the Future of the web platform. This talk reminds me of Angular methodology where you are adding custom tags to HTML.

As well  Peter Gasston talks about web components and CSS. Example of video player which runs on javascript, html, css.  If you show hidden dom, you can see markup.

Show shadow dom in web tools under wrench:





shadow root, host, dom

shadow root:
var newroot  = $(foo).createShadowRoot(), newElem =  '<h2<test</h2>' ;

newroot.innerHTML = newElem ;

<div id ="foo"><h1> First</h1></div>

div tag  is the shadow host, and h1 text replaces h2 with test.


widget example: <div id ="foo"><h1> First</h1></div>
want it but in different color
encapsulation - has all it needs contains within itslef, nothing gets in, nothing gets out
encapsulation in html is iframe today - issues extra network, multiplee rendering, cross orgin conflicts
better encapsulation is web components
reusable web components - shadowdom, templates,  custom tags

templates - put stuff in it

<template id ="foo"><h2> First</h2></template>
<div id ="bar"><h1>text 2</h1></div>

mark up inside is inert - does nothing, does not get loaded

inside template known as content

var test = $(foo).content.cloneNode(true), bar = document.getElementById('bar');
bar.appendChild(test);

puts template inside bar div tag  - template active

share templates across multiple files using import



4 main areas (Shadow DOM gives encapsulation, templates or chunk of markup that later you can stamp out your elements, custom tags, html imports that can be reused via CDN URLs):



HTML templates:
Template out your markup 
Put dom in it
Parsed not rendered - won't run until you stamp it out, same for media
Hidden from document, cant traverse into,  its in its own context

Content property - document fragment , clone it, stamp it out, see whats in it

Example:


Clone it is what stamps it out (here it runs script when that happens):

http://www.webcomponentsshift.com/#15

New spec for html templates  : chrome supports it.


Shadow dom (Secret markup in elements):
markup encapsulation, DOM encapsulation, css style boundary protection, no bleeding in, style boundaries, exposes to developers mechanics browser vendors use to create their html elements

iframe has it but bloated, hard to use  (extra network requests needed, multiple rendering contexts)




Dom nodes can host hidden dom

hidden dom  can't be accessed by outside  javscript





Hidden document fragment

Using markup to control it

Browser vendors been holding out

http://www.webcomponentsshift.com/#23



Filled in markup

Shadow dom gets rendered


Style things

This time add styling make it red



@host

Host element provide default styles






Custom elements (require hyphen)

Ability to define new elements

Plunkr example 






Using js html.prototype 

http://www.webcomponentsshift.com/#35



Html imports




Tuesday, September 30, 2014

Polymer

Polymer approach:
Elements are pretty great. They’re the building blocks of the web. Unfortunately, as web apps got more complex, we collectively outgrew the basic set of elements that ships in browsers. Our solution was to replace markup with gobs of script. In that shift, we’ve lost the elegance of the element. Polymer returns to our roots. We think the answer is not gobs of script, but rather to build more powerful elements. A set of powerful new technologies called Web Components makes this possible.

Custom Elements:
Embracing the philosophy means a web app becomes a collection of well-defined, reusable components.




Using Elements



Creating Elements

https://www.youtube.com/watch?v=5b5O5cclPbk (web components overview)

- https://github.com/KamiQuasi/wc-overview
- natively without polyfills



Intro Polymer
- easier to create custom elements
- quiz application demo app w paper elements
- inimation 60 frames / sec

https://www.youtube.com/watch?v=3CJcHJGZfws (web components and polymer overview)



http://www.polymer-project.org/resources/video.html




http://www.polymer-project.org/docs/start/tutorial/intro.html
http://www.html5rocks.com/en/tutorials/webcomponents/template/
https://www.youtube.com/watch?v=eJZx9c6YL8k
http://www.polymer-project.org/docs/polymer/polymer.html#altregistration
http://www.polymer-project.org/docs/polymer/databinding.html
http://www.polymer-project.org/docs/polymer/databinding-advanced.html#autobinding

https://github.com/Polymer/observe-js

Thursday, September 25, 2014

Web Components 101

I recently watched Eric Bidelman's talk from Google I/O 2013 on Web Components.  This talk was on the Future of the web platform. This talk reminds me of Angular methodology where you are adding custom tags to HTML.

4 main areas (Shadow DOM gives encapsulation, templates or chunk of markup that later you can stamp out your elements, custom tags, html imports that can be reused via CDN URLs):











HTML templates:
Template out your markup 
Put dom in it
Parsed not rendered - won't run until you stamp it out, same for media
Hidden from document, cant traverse into,  its in its own context

Content property - document fragment , clone it, stamp it out, see whats in it

Example:


Clone it is what stamps it out (here it runs script when that happens):











New spec for html templates  : chrome supports it.




Shadow dom (Secret markup in elements):
markup encapsulation, DOM encapsulation, css style boundary protection, no bleeding in, style boundaries, exposes to developers mechanics browser vendors use to create their html elements

iframe has it but bloated, hard to use  (extra network requests needed, multiple rendering contexts)











Dom nodes can host hidden dom

hidden dom  can't be accessed by outside  javscript


Show shadow dom in web tools under wrench:







Hidden document fragment

Using markup to control it

Browser vendors been holding out
















Filled in markup

Shadow dom gets rendered


Style things

This time add styling make it red











@host

Host element provide default styles




















Custom elements (require hyphen)

Ability to define new elements

Plunkr example 





















































Using js html.prototype 

























































Html imports
































Tuesday, May 6, 2014

CSS Box Model


Examples...
margin-top:5px;
margin-left:16px;
padding-left:12px ;
border-bottom: 1px solid #ccc;

Tuesday, October 22, 2013

A Html5 Class

I stumbled across this web site and it looked like a great class.

http://aaltowebapps.com/

The class has all sorts of examples you can run such as Storage and Offline API, Templating with Handlebars, CSS Media Queries, and more. The example code is on GitHub too.

Lectures:

Mobile Web Appplications Development with HTML5 part 1
JQuery Mobile [examples]
Mobile Web Appplications Development with HTML5 part 2
Mobile Web Appplications Development with HTML5 part 3
Mobile Web Appplications Development with HTML5 part 4 [backbone] [Canvas/Device] [web sockets] [css3] [rest]

Other talks: http://aaltowebapps.com/talks.html - https://github.com/clody69

http://gitref.org/
www.html5rocks.com
www.htmlfivewow.com
chromestatus.com caniuse.com
http://mobilehtml5.org/

Try It In Real Time

http://www.sqlfiddle.com/ - learn and practice SQL queries online
JSBin  - Remy Sharp online javascript tool
JSFiddle 
CodePen
Dabblet  - CSS
Tinker

http://hugogiraudel.com/2012/11/19/css-playgrounds/

Thursday, September 19, 2013

Styling that Page


The CSS file is where we are tasked with finding the tag we must change to make the view look like we want it.

Dr. Patrick Young CSS lecture notes (pdf, 30 pages)
Lean  css-positioning - interactive html css site
http://www.bruceontheloose.com/htmlcss/appendixes/css-reference.php
http://www.htmldog.com/guides/css/
http://dret.net/lectures/web-spring11/   a class with a lot useful material and references
http://codevisually.com/css-resources/page/2/
Intro CSS
the 30 css selectors you must memorize/
CSS parody
http://www.d.umn.edu/itss/training/online/webdesign/css.html
css attractive website
http://www.d.umn.edu/itss/training/online/webdesign/html.html
http://zomigi.com/
http://comminfo.rutgers.edu
http://multimedia.journalism.berkeley.edu/tutorials/cat/webdev
http://www.webdesignfromscratch.com/category/html-css/
http://www.underworldmagazines.com/category/mobile/
http://sixrevisions.com/css/20-useful-resources-for-learning-about-css3/#more-375
mozilla css Getting Started
http://www.css3.info/
http://www.youtube.com/watch?v=H3KESBQTD8k&list=PLE0F12F375F9E9266
http://www.youtube.com/watch?v=GwQMnpUsj8I
The format of a selector is as follows

   Selector {property : value}

Type selector – targets selector by element name, can have comma and wild card *

Contextual Selectors – apply style to properties based on context or relation to another element


Descendant selector: descendants of another element, list separated by space starting with the higher level element, can have commas separating multiple entries, and can be specified several levels deep

Child selector: like a descendant but specified by a specific parent of an element, indicated as child with greater than sign between elements >

Adjacent selector: elements that comes directly after a certain element with same parent, indicated with plus sign

Class and Id selectors - specified in regard to specific elements which are a class or a specific ids specified by user.

  • For class you define it in terms of class in regards to a specific type selector with a dot separator. 
  • To specify class selector to all elements within a class you can leave out the type selector 
  • id selector target a single element and work like class selector except indicated with a #
Attribute selectors – targets specific attribute names or values


  • Simple attribute: specified for an attribute for an element, indicated as element[attribute] 
  • Exact attribute value : specified as element[attribute="myvalue"] 
  • Partial attribute value: doesnt match whole word but search value within attribute value , specified as element[attribute~="myvalue"] 
  • hyphen separated value : used for case where you look for value of ‘myvalue’ or starting with ‘myvalue-’ , indicated with |= 


Pseudeoclass selector : targets a group of elements such as an anchor. has a colon : after the anchor followed with the attribute kind (i.e. link, or name)

 there are others supported other than the anchor tag . i.e. :first-chld, :first-line, :first-letter,:before, :after

How you reference style sheets:

<link rel=style sheet href=file.css type=text/CSS />
or
@import url();

Document structure and inheritance
- parent child relationships
- sibling relationships
- descendants
- Inheritance : styles passed down to descendants

Overriding styles by nodes higher in hierarchy Can get presentation rules from several sources and conflicts

Passed down until overridden by command with more weight Resolve rules from competing style sheets

When user agent (ie browser) encounters element looks for all style rules that may apply Sorts out this out based on Style sheet origin

Least weight to greatest
1 User agent style sheet
2 reader style sheet
3 authorsyle sheets
4 !Important marked

External file sheets further down document greater precedence

Imported styles sheets override linked ones Embedded styles sheets override external ones Inline styles override other references

Selector More specific the selector the more priority it gets

Least to most priority for selectors follow

Individual element to pseudo element selector

Contextual selectors Class selectors Id selectors rule order Last one wins Display roles

Block level elements – line breaks before and after it and fills in width of the parent that contains it

Paragraph
Headings
Lists
Divs

Inline – no line breaks
Emphasized text
Anchors
None – Wont display
 List-item Run-in

Box model :


4 Background
3 Margin
2 Border
1 Padding
0 Element box around it

padding vs margin
a) padding - outer edge
b) margin - space between items

TRBL (Top Right Bottom Left)
-  margin: 2px 1px 3px 4px (top, right, bottom, left)

display inline vs block - display of block means multiple items can  NOT be displayed beside it (goes below), whereas inline means multiple items on same line (goes beside it)

Inner edge
Border
Margin
Outer edge

 Unit measures
    Pixel Pts Pc Em Ex In Mm Cm

 Color value
   % values