Top Banner
CSS For Geographers Patrick Arlt | @patrickarlt Slides: http://bit.ly/2le4IJe
46

CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Sep 01, 2019

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

CSS For GeographersPatrick Arlt | @patrickarlt

Slides: http://bit.ly/2le4IJe

Page 2: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

This talk is all fundamentals.

Page 3: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

First Some NotesLots of supplemental info in these slides.

Designed to help you keep learning beyond this talk.

Page 4: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

CSS is HardCloser to art then computer science

Lots of hard, unintuitive concepts

It has taken me years to amass this knowledge

Page 5: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Lets do stuff with CSS!Customize Esri Apps

Use Frameworks

Build Web Pages

Make Apps

Page 6: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Basics

Page 7: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Where does CSS go?

Inside a <style> tag.

Inside a .css �le that is loaded with a <link> tag.

In the <head> tag of your .html �les.

<link href="file.css" rel="stylesheet" type="text/css">

Page 8: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

What does CSS look like?

html, body, #map { margin: 0; width: 100%; height: 100%; }

Page 9: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Selector

html, body, #map       

Page 10: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Declaration

html, body, #map {    }

Page 11: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Property

html, body, #map { margin:   }

Page 12: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Value

html, body, #map { margin: 0;   }

Page 13: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Property

html, body, #map { margin: 0; width:  }

Page 14: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Value

html, body, #map { margin: 0; width: 100%;  }

Page 15: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Property

html, body, #map { margin: 0; width: 100%; height: }

Page 16: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Value

html, body, #map { margin: 0; width: 100%; height: 100%; }

Page 17: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

A CSS Rule

html, body, #map { margin: 0; width: 100%; height: 100%; }

Page 18: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

How does CSS work?The "C" is for Cascading

Page 19: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Cascading Style SheetsStyles from different sources cascade and coalesce into the �nal styles for

the HTML tags that match their selectors.

Page 20: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

A Typical Cascade

Browser default stylesheet

User de�ned stylesheets

Stylesheets you include with <link>

<style> tags

Inline <style> attributes <div style="...">

CSS values with !important

Page 21: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

CSS Speci�cityWhen properties collide speci�city determines which property wins.

1. Rules with !important

2. Inline styles <div style="...">

3. <style> and <link> tags

4. Selector speci�city

Page 22: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Selector Speci�city

1. #foo - <div id="foo">

2. .foo - <div class="foo">

3. tag - <div>

CSS Explain

Page 23: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

In a speci�city tie the last loaded rule wins.

Page 24: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

In PracticeRight click on something you want to change click "Inspect Element"

Explore a Storymap

Page 25: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Lets Build an App!

Page 29: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Problems with Floats

Page 35: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Margin, Padding and BordersMastering margin collapsing

What You Should Know About Collapsing Margins

Compare block elements to pictures hanging on a wall

Page 39: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Typography (Sizing Type)TypeScale

A More Modern Scale for Web Typography

Page 42: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Browser CompatibilitySometime browsers will add experimental or early support for a new

standard. They will often add a pre�x like -webkit- , -moz- or -ms-to a property or value.

Sites like or to check if browsers support a speci�cproperty.

Can I Use? MDN

Tools like to add pre�xes automatically.Autopre�xer

Page 43: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

More Browser CompatibilityRemember Microsoft only supports IE 11 of�cially now. All other versions

are not supported and might have security bugs.

Scary!

Page 44: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Best PracticesKeep selectors as simple as possible

Don't use tools until you are familiar with the basics

Watch out for the size of web fonts

Page 45: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

More _______ for GeographersGit/Github for Geographers

Wednesday 5:30pm, Santa Rosa

JavaScript for Geographers

Thursday 9am, Demo Theater 1 - Oasis 1

CSS for Geographers

Friday 1pm, Pasadena-Sierra-Ventura

Page 46: CSS for Geographers - Recent Proceedingsproceedings.esri.com/library/userconf/devsummit17/papers/dev_int_36.pdf · CSS is Hard Closer to art then computer science Lots of hard, unintuitive

Thank You!Slides - http://bit.ly/2le4IJe

Leave Feedback

Download the Esri Events App

Go to Dev Summit

Select "CSS for Geographers"

Leave a Review!