Viewport, custom CSS, fonts

Similar documents
FOR THOSE WHO DO. Lenovo Annual Report

TITLE - Size 16 - Bold

BOOTSTRAP AFFIX PLUGIN

MKA PLC Controller OVERVIEW KEY BENEFITS KEY FEATURES

The L A TEX Template for MCM Version v6.2

Example project Functional Design. Author: Marion de Groot Version

Paper Template for INTERSPEECH 2018

Intermediate District 288. Brand Manual. Visual Identity Guide

Brand Guidelines MAY 2016

The Next Big Thing Prepared for Meeting C

Timon Hazell, LEED AP Senior BIM Engineer. Galen S. Hoeflinger, AIA BIM Technologist Manager

Thomas F. Sturm A Tutorial for Poster Creation with Tcolorbox

Creating An Effective Academic Poster. ~ A Student Petersheim Workshop

Connected TV Applications for TiVo. Project Jigsaw. Design Draft. 26 Feb 2013

Thomas F. Sturm A Tutorial for Poster Creation with Tcolorbox

COLORS COLOR USAGE LOGOS LOCK UPS PHOTOS ELEMENTS ASSETS POWERPOINT ENVIRONMENTAL COLLATERAL PROMO ITEMS TABLE OF CONTENTS

Brand identity guidelines

An output routine for an illustrated book

Gestures: ingsa GESTURES

A Road To Better User Experience. The lonely journey every front-end developer must walk.

TITLE SUBTITLE Issue # Title Subtitle. Issue Date. How to Use This Template. by [Article Author] Article Title. Page # Article Title.

American Political Science Review (APSR) Submission Template ANONYMISED AUTHOR(S) Anonymised Institution(s) Word Count: 658

TITLE. Tips for Producing a Newsletter IN THIS ISSUE

ALWAYS MOVING FORWARD MIDWAY S GRAPHIC IDENTITY STANDARDS MANUAL

BRAND GUIDELINES All rights reserved.

Insights. Send the right message to the right person at the right time.

Colors. F0563A Persimmon. 3A414C Cobalt. 8090A2 Slate Shale. C4CDD6 Alloy Coal. EFF3F5 Silver. EDF3F9 Horizon.

VISUAL IDENTITY STARTER KIT FOR ENSURING OUR COMMUNICATIONS ARE COHESIVE, CONSISTENT AND ENGAGING 23 OCTOBER 2008

The everyhook package

DFSA - Web Site Revamp

Project Title. A Project Report Submitted in partial fulfillment of the degree of. Master of Computer Applications

VISUAL. Standards Guide

src0-dan/mobile.html <!DOCTYPE html> Dan Armendariz Computer Science 76 Building Mobile Applications Harvard Extension School

Brand identity design. Professional logo design + Branding guidelines + Stationery Designed by JAVIER

Ghislain Fourny. Big Data 2. Lessons learnt from the past

City of Literature Branding

[Main Submission Title] (Font: IBM Plex Sans Bold, 36 point)

Row 1 This is data This is data

Row 1 This is data This is data. This is data out of p This is bold data p This is bold data out of p This is normal data after br H3 in a table

<!-- Bootstrap core CSS --> <link href=" ap.min.css" rel="stylesheet">

RHYMES WITH HAPPIER!

I D E N T I TY STA N DA R D S M A N UA L Rev 10.13

BRAND IDENTITY GUIDELINE

Teach Yourself Microsoft Publisher Topic 2: Text Boxes

BBN ANG 183 Typography Lecture 5A: Breaking text

RML Example 48: Paragraph flow controls

TUSCALOOSA CITY SCHOOLS Graphic Standards and Logo Use Guide

Personal brand identity desigend by JAVIER

Making the New Notes. Christoph Noack OpenOffice.org User Experience Max Odendahl OpenOffice.org Development Christian Jansen Sun Microsystems

This is the Title of the Thesis

The POGIL Project Publication Guidelines

The pdfreview package

Thesis GWU Example Dissertation. by Shankar Kulumani

Style guide. March 2017 CC BY 4.0 The Tor Project

Brand Guide. Last Revised February 9, :38 PM

OCTOBER 16 NEWSLETTER. Lake Mayfield Campground OR-LOW GOOD TIMES

Creating Websites without Code. Jesse Clark, Webmaster University of Northern Colorado

Wandle Valley Branding Guidelines 1

Visual identity guideline. BrandBook BLOOMINGFELD. Brandbook 2016.

lipsum Access to 150 paragraphs of Lorem Ipsum dummy text a

CITIZEN SCIENCE DATA FACTORY

IDENTITY STANDARDS LIVINGSTONE COLLEGE DR. JIMMY R. JENKINS, SR. PRESIDENT

Version 1.4 March 15, Notes Bayer- Kogenate 2010 WFH Microsoft Surface Project (HKOG-39563) Information Architecture Wireframes

BRAND GUIDELINES VAN S AIRCRAFT, INC. VERSION V1.1

WRAS WIAPS BRAND GUIDELINES 2015

Faculty Web Pages: Editing the Template Prepared by Tamara Fudge, June 2008

Overly Companies (OSA, BRICO)

Are You Using Engagement TilesTM?

CORPORATE IDENTITY MANUAL

cosmos a tech startup

The colophon Package, v1.1

CLASSES are a way to select custom elements without using a tag name

Prototyping Robotic Manipulators For SPHERES

NATURAL BUILDING TECHNOLOGIES Document: Feedback Sheet Revision: A Date: 13/07/16 Queries:

Compassion. Action. Change.

THE ESPRESSO BOOK MACHINE PUBLISH INSTANTLY AT THE MSU LIBRARIES

file:///users/nma/desktop/chris_mac/chris_school/kcc_nmawebsite/_technology/sitebuild/htdocs/gargiulo/data/johndoe/spring/art128...

BBN ANG 183 Typography Lecture 5A: Breaking text

Whitepaper. Call to Action

Word Processing Fundamentals

Abstract. Author summary. Introduction

Formatting Theses and Papers using Microsoft Word

RPM FOUNDATION BRANDING GUIDELINES AND GRAPHIC STANDARDS

Invoice Visual Design Specifications MEC

CLASP Website Redesign Client Deliverables Spring 2007

DISTRIBUTED MEMORY COMPUTING IN ECONOMICS USING MPI

Creating Websites without Code. Jesse Clark Manager of Web Communications University of Northern Colorado

Saturday January 6, pm

Foundation Site Global Elements

AMERICA'S CAR MUSEUM BRANDING GUIDELINES AND GRAPHIC STANDARDS

9 Ways You Can Put Behavioral Automation to Work.

Certified Organisation logo guidelines. Version 1.0 April 2018

NCATS Branding System. Branding Elements 2 Color Palette 3 Typography 4 Imagery 5-6 Iconography 7 Applications 8-16

Visual Identity Standards

Pablo- Alejandro Quiñones. User Experience Portfolio

Identity Guidelines Version_1

template guidelines. 1. Visual identity 2. How to build an

v 1.01 WEB STYLE GUIDE

UNIVERSITY OF CALGARY. An Important Contribution to the Literature. Jane Mary Doe A THESIS SUBMITTED TO THE FACULTY OF GRADUATE STUDIES

Chaparral Sports Day. Basketball Ashley Guerrero(captain), Carrera, Rasuly, Hamilton Alba, Razel Alba, Bannister, Phillips, Richardson.

Transcription:

CS120 Web Development LIU 1 of 9 Viewport, custom CSS, fonts Running a web server (optional) When creating basic static web sites, it s entirely possible to test them in your browser just using a file:// URL. That s what you get when you just select a.html file on your disk and select Open with then a browser. (So the same file is open in your editor and in your browser.) But as we start using Javascript and other features, it can be helpful to load the pages and linked resources through an actual HTTP connection. Another use case where this helps is if you want to edit on one device (laptop) and view on another (smartphone). There are several ways to run a web server on your development machine, but one of the simplest is to use Python. On a Mac, you probably already have Python installed. On Windows, it s easy to install just make sure in the installation that you enable the checkbox which says Add to PATH. Your Python executable is probably called one of python or python2 or python3. Figure out which ones work by trying these commands: python --version python2 --version python3 --version As long as one of those succeeds, we should be alright. If you have one which reports version 3.something then here s the command you need to run the web server (substitute your working python command): python -m http.server If instead you have a version 2.something, the command is slightly different: python -m SimpleHTTPServer The output will be something like: Serving HTTP on 0.0.0.0 port 8000... Next you just need to know the IP address of your laptop, where you re running this command. Check your network settings or run ipconfig (Windows) or ifconfig (Mac) in another terminal.

2 of 9 Prof. League Spring 2018 Viewport, custom CSS, fonts On another device, you ll be able to access the web server at http://ip_address:8000/filename.html where you substitute the capitalized portions of that URL appropriately. Security warning: This technique exposes all files within the directory you re running (and subdirectories) to anyone on your network. So make sure you re in an isolated directory where the only thing there is to see is the web site you re working on! Firewall note: If you are running a Firewall on your laptop, then this connection probably won t work. You ll have to configure port 8000 to be allowed through the firewall, or (perhaps temporarily) disable the firewall to connect. Mobile viewport header When we used the above technique to access the Bootstrap demo page we created in the previous notes from a smartphone, we noticed that it wasn t adapting to the smaller screen size: By default, mobile browsers pretend they have a full desktop screen size, and show that version of the site, but zoomed way out. This makes the text hard to read, although the user can pinch and double-tap to zoom the view in on particular blocks of text. This behavior is in spite of the fact that Bootstrap does support collapsing columns, as we saw when we adjust the size of the browser window on a desktop. To get the mobile browser to act as a true mobile screen size, you need to add a viewport declaration to your page. It looks like this, and goes in the <head> section: <meta name="viewport" content="width=device-width, initial-scale=1.0"> With that one line added, now the mobile browser displays the same content formatted as a mobile web site: Custom CSS and selector syntax After the link tag that fetches the bootstrap.min.css, we can still add a custom CSS style block, like this: <style type="text/css"> h1 { text-align: center; color: #373; </style>

CS120 Web Development LIU 3 of 9 Figure 1: Bootstrap demo on smartphone browser

4 of 9 Prof. League Spring 2018 Viewport, custom CSS, fonts Figure 2: Top and bottom of bootstrap-demo with viewport setting

CS120 Web Development LIU 5 of 9 Above, we re using a selector based only on the name of an element in this case the h1 element. But what if we want to distinguish particular h1 elements, or subsets of them? The best way is to mark those h1 elements with a class or id attribute. For example, we could create <h1 class="important"> and then match it with a rule like this: h1.important { border-bottom: 1px solid blue; background: #fee; font-style: italic; The dot in the selector syntax, h1.important means that it applies to all h1 elements that have a class of important. (The name important doesn t have any special meaning in CSS, it s just an identifier we could have used class="susan" and h1.susan for the same effect.) The id attribute can be used similarly, except the intention is that there is only one element with any particular id it should be a unique identifier. The syntax for an id-based selector uses a hash sign: h1#winner to match <h1 id="winner">: h1#winner { color: #337; There are lots of other capabilities in the selector syntax. You can use spaces to indicate descendants (children and their children), so that div.row p.warning matches an element with <p class="warning"> but only if it s within a <div class="row">. There are also selector predicates marked with colons. Two that I demonstrated in class were :first-child and :hover. You can see those in action in the complete sample page, but here are the CSS rules: div.links :first-child { text-align: center; font-weight: bold; div.link:hover { background: #555; color: yellow; On the sample page, try hovering your mouse over the items in the footer.

6 of 9 Prof. League Spring 2018 Viewport, custom CSS, fonts Google fonts Customizing the fonts on your page can be tricky because you don t know what fonts the user has installed on their system. You specify them with the CSS font-family attribute, which can take a list of families and apply the first one that is available, like this: body { font-family: "Chicago", "Minion Pro", "Times Roman", serif; The last element in that list is a fallback there are certain generic family names that are guaranteed to be defined: serif, sans-serif, monospace, cursive, etc. Rather than relying on fonts installed on the user s system, it may be preferable to load a custom font from the page. There are different services for this, but perhaps the simplest and cheapest is Google fonts. You select some fonts from that page and add them to your cart. Then from the cart you can get a link that you d paste into your page <head> and your CSS <style> block. On the example page, I used EB Garamond and Pacifico like this: <link href="https://fonts.googleapis.com/css?family=eb+garamond Pacifico" rel="stylesheet"> body { font-family: 'EB Garamond', serif; h1 { font-family: 'Pacifico', cursive; Complete example Here is the modified bootstrap demo code using all the features above. The live version is here. <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-gn5384xqq1aowxa+058rxpxpg6fy4iwvtnh0e263xmfcjlsawiggfaw/dais6jxm" crossorigin="anonymous"> <link href="https://fonts.googleapis.com/css?family=eb+garamond Pacifico" rel="stylesheet"> <style type="text/css">

CS120 Web Development LIU 7 of 9 body { font-family: 'EB Garamond', serif; h1 { font-family: 'Pacifico', cursive; text-align: center; color: #373; h1.important { border-bottom: 1px solid blue; background: #fee; font-style: italic; h1#winner { color: #337; div.links :first-child { text-align: center; font-weight: bold; div.link:hover { background: #555; color: yellow; </style> </head> <body> <div class="container" style=""> <div class="row"> <div class="col-md-5"> <h1 id="winner">article one</h1> <img class="img-fluid img-thumbnail" src="cats-animals-kittens-background-us <p> Aliquam erat volutpat. Nunc eleifend leo vitae magna. In id erat non orci commodo lobortis. Proin neque massa, cursus ut, gravida ut, lobortis eget, lacus. Sed diam. Praesent fermentum tempor tellus. Nullam tempus. Mauris ac felis vel velit tristique imperdiet. Donec at pede. Etiam vel neque nec dui dignissim bibendum. Vivamus id enim. Phasellus neque orci, porta a, aliquet quis, semper a, massa. Phasellus purus. Pellentesque tristique imperdiet tortor. Nam euismod tellus id erat. </p>

8 of 9 Prof. League Spring 2018 Viewport, custom CSS, fonts <div class="col-md-7"> <h1 class="important">article 2</h1> Pellentesque dapibus suscipit ligula. Donec posuere augue in quam. Etiam vel tortor sodales tellus ultricies commodo. Suspendisse potenti. Aenean in sem ac leo mollis blandit. Donec neque quam, dignissim in, mollis nec, sagittis eu, wisi. Phasellus lacus. Etiam laoreet quam sed arcu. Phasellus at dui in ligula mollis ultricies. Integer placerat tristique nisl. Praesent augue. Fusce commodo. Vestibulum convallis, lorem a tempus semper, dui dui euismod elit, vitae placerat urna tortor vitae lacus. Nullam libero mauris, consequat quis, varius et, dictum id, arcu. Mauris mollis tincidunt felis. Aliquam feugiat tellus ut neque. Nulla facilisis, risus a rhoncus fermentum, tellus tellus lacinia purus, et dictum nunc justo sit amet elit. <!-- col --> <!-- row --> <div class="row" style="margin-top: 3ex; padding-top: 3ex; background-color: #eee"> <div class="links col-md-3"> <div class="link">one <div class="link">two <div class="link">three <div class="links col-md-3"> <div class="link">four <div class="link">five <div class="link">six <div class="links col-md-3"> <div class="link">seven <div class="link">eight <div class="link">nine <div class="link">ten <div class="links col-md-3"> <div class="link">eleven <div class="link">twelve <!-- row --> <!-- container -->

CS120 Web Development LIU 9 of 9 </body> </html>