/
DOM, HTML, CSS DOM, HTML, CSS

DOM, HTML, CSS - PowerPoint Presentation

natalia-silvester
natalia-silvester . @natalia-silvester
Follow
402 views
Uploaded On 2017-06-08

DOM, HTML, CSS - PPT Presentation

UI Development Basics Confidential Intro Confidential 2 How it works render process How to choose layout architecture Performance optimization Expectation Confidential 3 Agenda Confidential ID: 557187

confidential left style top left confidential top style bstyle tree layout dom render var reflow offsetleft html offsettop source

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "DOM, HTML, CSS" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

DOM, HTML, CSS

UI Development Basics

ConfidentialSlide2

Intro

Confidential

2Slide3

How it works (render process)

How to choose layout architecture

Performance

optimization

Expectation

Confidential

3Slide4

Agenda

Confidential

4Slide5

The rendering process

HTML Source/DOM tree/DOM Render

Confidential

5Slide6

HTML

source The

DOM

tree The

 render tree

HTML Source/DOM tree/DOM Render

Confidential

6Slide7

Parts of the render tree (or the whole tree) will need to be revalidated and the node dimensions recalculated. This is called a

reflow

, or

relayout

, or

relayouting

. Note that there's at least one reflow - the initial

layout of the

page.

Parts of the screen will need to be updated, either because of changes in geometric properties of a node or because of stylistic change, such as changing the background color. This screen update is called a

repaint

, or a

redraw

.

Repaints and

reflows

Confidential

7Slide8

Task (repaint or reflow ?)

Repaints and

reflows

Confidential

8

var

bstyle

=

document

.

body

.

style

;

bstyle

.

padding

=

"

20px

"

;

bstyle

.

border

=

"

10px solid red

"

;

bstyle

.

color

=

"

blue

"

;

bstyle

.

backgroundColor

=

"

#fad

"

;

bstyle

.

fontSize

=

"

2em

"

;

document

.

body

.

appendChild

(

document

.

createTextNode

(

'

dude!

'

))

;

Var

left

=

el

.

offsetLeft

;

Slide9

Reflow (

offsetTop

,

offsetLeft

,

offsetWidth

, offsetHeight

scrollTop

/Left/Width/Height

clientTop

/Left/Width/Height

Repaints and reflows

Confidential

9

// no-no!

for

(

big

;

loop

;

here

)

{

el

.

style

.

left

=

el

.

offsetLeft

+

10

+

"

px

"

;

el

.style.top = el.offsetTop + 10 + "px"; } // better var left = el.offsetLeft, top = el.offsetTop, esty = el.style;for(big; loop; here) { left += 10; top += 10; esty.left = left + "px"; esty.top = top + "px"; }

// bad

var

left

=

10

,

top

=

10

;

el

.

style

.

left

=

left

+

"

px

"

;

el

.

style

.

top

=

top

+

"

px

"

;

// better

el

.

className

+=

"

theclassname

"

;

// or when top and left are calculated dynamically...

// better

el

.

style

.

cssText

+=

"

; left:

"

+

left

+

"

px

;

top:

"

+

top

+

"

px

;

"

;

Slide10

Layout

architecture

Confidential

10Slide11

Why Table Layout is a bad practice?

Why

“Float”

Layout is a bad practice

?

Absolute, “Percentage”, Flex, Inline-Block how to choose The Best.

Layout

architecture

Confidential

11Slide12

Confidential

12

The End

Thank you for your

attention!