CSCI 2133
CSCI 2133 – Rapid Programming Techniques for Innovation
CSS, CSS3, SASS/SCSS
CSCI 2133 Rapid Programming Techniques for Innovation CSS, CSS3, - - PowerPoint PPT Presentation
CSCI 2133 Rapid Programming Techniques for Innovation CSS, CSS3, SASS/SCSS CSCI 2133 2 Previous Lecture HTTP 1/2 HTML / HTML5 CSCI 2133 H T M L 5O V E R V I E W HTML5 is the new standard, which includes: New HT
CSCI 2133
CSS, CSS3, SASS/SCSS
CSCI 2133
2
CSCI 2133
HTML5 is the new standard, which includes:
◉ New HT ML elements and attributes ◉ Full C S S 3 Support ◉ Video and audio elements ◉ 2D/3D graphics ◉ Local storage ◉ Local S Q L database
CSCI 2133
media content. Please find below the tags used for the same:
and <video> contents
<audio> and <video> elements.
4
CSCI 2133
“day_time”>
value= “5”>
max= “10”>
5
CSCI 2133
<canvas id="myCanvas">Your browser does not support the HTML5 canvas tag.</canvas> <script> var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.fillStyle = "#FF0000"; ctx.fillRect(0, 0, 80, 100); </script>
<svg height="100" width="100"> <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /> Sorry, your browser does not support inline SVG. </svg>
6
CSCI 2133
LOcalStorage Usage: // Store localStorage.setItem("lastname", "Smith"); // Retrieve document.getElementById("result").innerHTML = localStorage.getItem("lastname"); SessionStorage usage: //Assign:
sessionStorage.yourAttr = yourVal;
7
CSCI 2133
8
CSCI 2133
9
CSCI 2133
CSCI 2133
CSCI 2133
Styles define how to display HTML elements
CSCI 2133
Styles define how to display HTML elements C S S can solve many design problems without adding images or changing the HTML
CSCI 2133
Because of CSS
CSCI 2133
CSCI 2133
html
Selector
CSCI 2133
Selector Declaration Declaration
html {margin:0; padding:0}
CSCI 2133
Property Property Selector Declaration Declaration
html {margin:0; padding:0}
CSCI 2133
Value Value Property Property Selector Declaration Declaration
html {margin:0; padding:0}
CSCI 2133
Value Value Property Property Selector Declaration Declaration
html {margin:0; padding:0} body {background-color:#d20c0c;}
CSCI 2133
Value Value Property Property Selector Declaration Declaration
html {margin:0; padding:0} body {background-color:#d20c0c;} h1 {font-size:12px;}
CSCI 2133
CSCI 2133
HTML element(s).
CSCI 2133
HTML element(s). CSS selectors are used to "find" (or select) HTML elements based on their id, classes, types, attributes, and more.
CSCI 2133
CSCI 2133
element name. (e.g. body, header, p,footer)
CSCI 2133
element name. (e.g. body, header, p,footer)
can only be used once (e.g. #main, #content, #footer)
CSCI 2133
element name. (e.g. body, header, p,footer)
can only be used once (e.g. #main, #content, #footer)
names and cans be reused (e.g. .wrapper, .column, .panel, .panel-pane)
CSCI 2133
CSCI 2133
elements
CSCI 2133
ID’s elements
CSCI 2133
ID’s classes elements
CSCI 2133
Links C S S files (the preferred method)
CSCI 2133
<p style=“color:red;”>Some Text</p>
Inline Styles
Result
CSCI 2133
{color:red;}</style> <head> <style>p </head>
Embedded Styles
Result
CSCI 2133
<head> <link rel="stylesheet" type="text/css" href=“style.css"> </head>
External Style Sheet reference
Result
p {color:red;}
style.css
CSCI 2133
CSCI 2133
border). The margin does not have a background color, and is completely transparent. The top, right, bottom, and left margin can be changed independently using separate properties.
CSCI 2133
50px 75px 100px
{margin:25px 50px 75px 100px;}
25px
CSCI 2133
and the elementcontent The top, right, bottom, and left padding can be changed independently using separate properties.
CSCI 2133
{padding:25px 50px 75px 100px;}
25px 50px 75px 100px
CSCI 2133
{padding:25px 50px 75px 100px;} {margin:25px 50px 75px 100px;}
border
CSCI 2133
Vivamus dignissim nunc eleifend, commodo mi sed, aliquam ante. Donec id lacus eu lectus sollicitudin viverra. Curabitur congue ultricies elit, at euismod mauris iaculis
justo.“Donec et molestie purus”. Cras et faucibus est, a viverra odio. Praesent luctus vel purus non mollis. In luctus vitae lectus quis fringilla. Curabitur porttitor justo ac dolor iaculis convallis.
p {font-family:Georgia Times serif;} a {color:$blue; text-decoration:underline;} .quote {color:$red; font-style:italic;}
CSCI 2133
CSCI 2133
element. The most common pseudo-classesare links Links can be styled differently depending on what state they are in.
a:link Selects a unvisited link a:visited Selects visited links a:active Selects the active link a:hoverSelects links on mouse
p::first-letter Selects the first letter of a paragraph p::first-line Selects the first line of a paragraph
CSCI 2133
46
CSCI 2133
CSCI 2133
effects of an element.
CSCI 2133
effects of an element. background-color sets the background color of an element
CSCI 2133
effects of an element. background-color sets the background color of an element background-image sets the background image for an element
CSCI 2133
effects of an element. background-color sets the background color of an element background-image sets the background image for an element background-repeat sets how a background image will be repeated
CSCI 2133
effects of an element. background-color sets the background color of an element background-image sets the background image for an element background-repeat sets how a background image will be repeated background-attachment sets whether a background image is fixed or scrolls with the rest of the page
CSCI 2133
effects of an element. background-color sets the background color of an element background-image sets the background image for an element background-repeat sets how a background image will be repeated background-attachment sets whether a background image is fixed or scrolls with the rest of the page background-position sets the starting position of a background image
CSCI 2133
effects of an element. background-color sets the background color of an element background-image sets the background image for an element background-repeat sets how a background image will be repeated background-attachment sets whether a background image is fixed or scrolls with the rest of the page background-position sets the starting position of a background image background sets all the background properties in one declaration
CSCI 2133
effects of an element. background-color sets the background color of an element background-image sets the background image for an element background-repeat sets how a background image will be repeated background-attachment sets whether a background image is fixed or scrolls with the rest of the page background-position sets the starting position of a background image background sets all the background properties in one declaration
CSCI 2133
CSCI 2133
The CSS positioning properties allow you to position an element.
CSCI 2133
element. Elements can be positioned using the top, bottom, left, and right properties.
CSCI 2133
element. Elements can be positioned using the top, bottom, left, and right properties. position:static is the default position of an element
CSCI 2133
element. Elements can be positioned using the top, bottom, left, and right properties. position:static is the default position of an element position:fixed tells an element to be positioned relative to the browser window. It will not move even if the window is scrolled
CSCI 2133
element. Elements can be positioned using the top, bottom, left, and right properties. position:static is the default position of an element position:fixed tells an element to be positioned relative to the browser window. It will not move even if the window is scrolled position:relative tells an element to be positioned relative to its normal position.
CSCI 2133
element. Elements can be positioned using the top, bottom, left, and right properties. position:static is the default position of an element position:fixed tells an element to be positioned relative to the browser window. It will not move even if the window is scrolled position:relative tells an element to be positioned relative to its normal position. position:absolute tells an element where to be positioned relative to its parent element.
CSCI 2133
{position:static;} {position:static;}
CSCI 2133
{position:static;} {position:static;}
CSCI 2133
{position:static;} {position:static;} {position:static;} {position:fixed;}
CSCI 2133
{position:static;} {position:static;} {position:static;} {position:fixed;}
CSCI 2133
{position:relative;} {position:absolute;} {position:static;} {position:static;} {position:static;} {position:fixed;}
CSCI 2133
{position:relative;} {position:absolute;} {position:static;} {position:static;} {position:static;} {position:fixed;}
CSCI 2133
CSCI 2133
With CSS float, an element can be pushed to the left or right, allowing other elements to wrap around it.
CSCI 2133
left or right, allowing other elements to wrap around it. clear Specifies which sides of an element where
CSCI 2133
left or right, allowing other elements to wrap around it. clear Specifies which sides of an element where
float Specifies whether or not a box should float to the left or right.
CSCI 2133
img {float:none;}
CSCI 2133
img {float:none;} img {float:left;}
CSCI 2133
img {float:none;} img {float:left;} img {float:right;}
CSCI 2133
img {float:none;} img {float:left;} img {float:right;}
aliquam ante. Donec id lacus eu lectus sollicitudin viverra. Curabitur congue ultricies elit, at euismod mauris iaculis
vel urna ac, dictum lobortis justo.“Donec et molestie
CSCI 2133
img {float:none;}
aliquam ante. Donec id lacus eu lectus sollicitudin viverra. Curabitur congue ultricies elit, at euismod mauris iaculis
vel urna ac, dictum lobortis justo.“Donec et molestie
purus non mollis. In luctus vitae lectus quis fringilla. Curabitur porttitor justo ac dolor iaculis convallis.
img {float:left;} img {float:right;}
aliquam ante. Donec id lacus eu lectus sollicitudin viverra. Curabitur congue ultricies elit, at euismod mauris iaculis
vel urna ac, dictum lobortis justo.“Donec et molestie
CSCI 2133
img {float:none;}
aliquam ante. Donec id lacus eu lectus sollicitudin viverra. Curabitur congue ultricies elit, at euismod mauris iaculis
vel urna ac, dictum lobortis justo.“Donec et molestie
purus non mollis. In luctus vitae lectus quis fringilla. Curabitur porttitor justo ac dolor iaculis convallis.
aliquam ante. Donec id lacus eu lectus sollicitudin viverra. Curabitur congue ultricies elit, at euismod mauris iaculis
vel urna ac, dictum lobortis justo.“Donec et molestie
purus non mollis. In luctus vitae lectus quis fringilla. Curabitur porttitor justo ac dolor iaculis convallis.
img {float:left;} img {float:right;}
aliquam ante. Donec id lacus eu lectus sollicitudin viverra. Curabitur congue ultricies elit, at euismod mauris iaculis
vel urna ac, dictum lobortis justo.“Donec et molestie
CSCI 2133
CSCI 2133
and the visibility property specifies if an element should be visible or hidden.
CSCI 2133
and the visibility property specifies if an element should be visible or hidden. visibility:hidden hides an element, but it will still take up the same space asbefore.
CSCI 2133
and the visibility property specifies if an element should be visible or hidden. visibility:hidden hides an element, but it will still take up the same space asbefore. display:none hides an element, and it will not take up any space.
CSCI 2133
Box shadow, text shadow Media Types Font face _____________________ Opacity -- demo Border radius -- demo Gradients -- demo
CSCI 2133
CSCI 2133
CSCI 2133
value from 0.0 - 1.0. A lower value makes the element more transparent.
{opacity:0.1;} {opacity:0.5;} {opacity:1.0;}
CSCI 2133
different layout for screen, print, mobile phone, tablet, etc.
CSCI 2133
different layout for screen, print, mobile phone, tablet, etc. all Used for all media type devices
CSCI 2133
different layout for screen, print, mobile phone, tablet, etc. all Used for all media type devices printUsed for printers
CSCI 2133
different layout for screen, print, mobile phone, tablet, etc. all Used for all media type devices printUsed for printers screen Used for computer screens
CSCI 2133
different layout for screen, print, mobile phone, tablet, etc. all Used for all media type devices printUsed for printers screen Used for computer screens tv Used for television-type devices
CSCI 2133
credit t to w3 w3school
"lightblue" when the browser window is 600px wide or less:
@media only screen and (max-width: 600px) { body { background-color: lightblue; } }
media, like this:
<link rel="stylesheet" media="screen and (min-width: 900px)" href="widescreen.css"> <link rel="stylesheet" media="screen and (max-width: 600px)" href="smallscreen.css">
92
CSCI 2133
93
CSCI 2133
94
There is also: screen, overlay, darken, lighten, color-dodge, color-
burn, hard-light, soft-light, difference, exclusion, hue, saturation, color,
and luminosity. And also normal which reset it.
CSCI 2133
95
CSCI 2133
@font-face { font-family: 'MyWebFont’; src: url('myfont.woff2') format('woff2’), url('myfont.woff') format('woff’); }
@import url(//fonts.googleapis.com/css?family=Open+Sans); body { font-family: 'Open Sans', sans-serif; }
96
CSCI 2133
CSCI 2133
CSCI 2133
Sass is a C S S preprocessor
CSCI 2133
Sass is a C S S preprocessor Sass can be written in either the sass or scss syntax
CSCI 2133
Sass is a C S S preprocessor Sass can be written in either the sass or scss syntax Sass files compile into css files
CSCI 2133
CSCI 2133
CSCI 2133
SA S S uses mixins (reusable blocks of styles)
CSCI 2133
SA S S uses mixins (reusable blocks of styles) SASS is faster, more efficient, and easier to maintain
CSCI 2133
SA S S uses mixins (reusable blocks of styles) SASS is faster, more efficient, and easier to maintain Using COMPASS with SA S S allows us to write many lines
CSCI 2133
Variable name Value
$yellow: #9d9624;
Mixin Extend
CSCI 2133
Variable name Value
$yellow: #9d9624; body
Mixin
{@include my-background;}
Extend
CSCI 2133
Variable name Value
$yellow: #9d9624; body h1
Mixin
{@include my-background;}
Extend
{@extend %my-background;}
CSCI 2133
CSCI 2133
nav { ul { } margin: 0; li { display: block; } a { padding: 6px 12px; color: $yellow; } }
SCSS
CSCI 2133
nav { ul { } margin: 0; li { display: block; } a { padding: 6px 12px; color: $yellow; } }
SCSS
nav ul margin: 0 block li display: a padding: 6px 12px color: $yellow
SASS
CSCI 2133
CSCI 2133
%my-background { margin-top: 12px; height: 10px; background: border: 1px red; solid $yellow; }
Define the placeholder selector
CSCI 2133
%my-background { margin-top: 12px; height: 10px; background: border: 1px red; solid $yellow; }
Define the placeholder selector
.box
Extend the placeholder selector
{@extend %my-background;}
CSCI 2133
%my-background { margin-top: 12px; height: 10px; background: border: 1px red; solid $yellow; }
Define the placeholder selector
.box
Extend the placeholder selector
{@extend %my-background;}
CSCI 2133
%my-background { margin-top: 12px; height: 10px; background: border: 1px red; solid $yellow; }
Define the placeholder selector
.box
Extend the placeholder selector
{@extend %my-background;}
CSCI 2133
CSCI 2133
@mixin my-background($radius) { margin-top: 12px; height: 10px; background: red; border-radius: $radius; }
Define the mixin
CSCI 2133
@mixin my-background($radius) { margin-top: 12px; height: 10px; background: red; border-radius: $radius; }
Define the mixin
.box
Include the mixin
{@include my-background(12px);}
CSCI 2133
@mixin my-background($radius) { margin-top: 12px; height: 10px; background: red; border-radius: $radius; }
Define the mixin
.box
Include the mixin
{@include my-background(12px);}
CSCI 2133
@mixin my-background($radius) { margin-top: 12px; height: 10px; background: red; border-radius: $radius; }
Define the mixin
.box
Include the mixin
{@include my-background(12px);}
CSCI 2133
CSCI 2133
CSCI 2133
.box,.footer {@include my-background(12px);}
CSCI 2133
.box,.footer {@include my-background(12px);}
Arguments
CSCI 2133
.box,.footer {@include my-background(12px);}
Arguments
.box,.footer {@extend %my-background;}
CSCI 2133
.box,.footer {@include my-background(12px);}
Arguments
.box,.footer {@extend %my-background;}
Smaller CSS
CSCI 2133
CSCI 2133
CSCI 2133
css-tricks.com
CSCI 2133
132
CSCI 2133
target the elements?
133
CSCI 2133