150 likes | 363 Views
More CSS and Bootstrap. Styling Backgrounds. CSS Properties background-color HEX, RGB, or named color background-image url to image file background-repeat background-attachment background-position Shorthand background: # ffffff url (‘ img.png ’) no-repeat right top;. Styling Text.
E N D
Styling Backgrounds • CSS Properties • background-color • HEX, RGB, or named color • background-image • url to image file • background-repeat • background-attachment • background-position • Shorthand • background: #ffffffurl(‘img.png’) no-repeat right top;
Styling Text • Text Color • {color:value;} • Value in HEX RGB or name • Text Alignment • {text-align:value;} • left, centered, right, justified • Text Decoration • {text-decoration:value;} • none, overline, line-through, underline, inherit • Text Transformation • {text-transform:value;} • none, uppercase, lowercase, capitalize, inherit
Styling Links • Link selectors • a:link– unvisited • a:visited – visited • a:hover – mouse over link • a:active – selected link • Common properties • text-decoration • color • background-color
Styling Lists • CSS Properties • list-style-image • {list-style-image:url(‘square.png’); • list-style-position • {list-style-position:value;} • inside, outside, inherit • list-style-type • {list-style-type:value;} • disk, decimal, circle, square, none, … • Shorthand • {list-style:square inside url(‘square.png’) • type, position, image
CSS Box Model • All HTML elements are considered as boxes Margin – clear area around the border, no background Border – area around the padding, background Padding – clear area around content, background Content – content of the element, background Margin Border Padding Content
Controlling the Box • <div class=“box”>Hello World</div> • .box { • width:250px; • padding:10px; • border:5px solid gray; • margin:10px; • } • How wide is the <div>?
Four sided Properties • Margin and Padding • margin-top, margin-right, margin-bottom, margin-left • Shorthand • margin: 25px 50px 75px 100px; • top is 25px • right is 50px • bottom is 75px • left is 100px • padding: 25px 50px 75px; • top is 25px • right and left is 50px • bottom is 75px • margin: 25px 50px; • top and bottom is 25px • right and left is 50px • padding: 30px • top, right, bottom and left are 30px
CSS3 Styles • Some new properties are defined in CSS3 • The support for these properties varies by browser • background-size-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover; • CSS functions • background-image: -webkit-gradient(linear,background-image: -webkit-linear-gradient(top, …background-image: -moz-linear-gradient(top, ...background-image: -ms-linear-gradient(top, …background-image: -o-linear-gradient(top, …background-image: linear-gradient(top, … • http://www.w3schools.com/cssref/css3_browsersupport.asp
QQ #2 • <body> • <header>This is the header</header> • <nav> • <a href="/html/">HTML</a> | • <a href="/css/">CSS</a> | • <a href="/js/">JavaScript</a> | • <a href="/jquery/">jQuery</a> • </nav> • <article> • <header>Article1 Header • <p>blah, blah, blah</p> • </header> • <p>Article Text</p> • </article> • <aside> • <header>Aside Header</header> • <p>Aside text</p> • </aside> <article> • <header>Article2 Header • <p>blah, blah, blah</p> • </header> • <p>Article Text</p> • </article> • <aside> • </body> • </html> What is the CSS selector to style all articles’ text? What is the CSS selector to style only the page’s header? What is the selector to style only article 2’s text?
Responsive Web Design • Creating Web sites that adjust to the media that renders them • CSS 2.1 provided media types • all • handheld • print • screen • … • Allows selecting the style sheet based upon the device <link rel=“stylesheet” type=“text/css” href=“core.css” media=“screen”/> <link rel=“stylesheet” type=“text/css” href=“print.css” media=“print”/>
CSS3 Media Queries • Allows inspection of physical characteristics of the device rendering the page • Media features • width: min-width, max-width • height: min-height, max-height • device-width: min and max • device-height: min and max • orientation: portrait or landscape • aspect-ratio: min and max • device-aspect-ratio: min and max • color: number of bits of color • monochrome
Media Queries • Media Query Format • media=“<operator>+ <media_type>+ (<media_feature>:<value>)+” • <link rel=“stylesheet” media=“not screen and (color)” href=“example.css”/> • @media <operator>+<media_type>+ (<media_feature>:<value>)+ • @media (max-width: 979px)
Combining Media Queries and CSS • Allows us to set the style of the web page based upon the device viewing the page • Large Screen • Printer • Tablet • Laptop • Phone • Mark the HTML element with classes • Style the classes differently based upon the Viewer
Twitter Bootstrap • Bootstrap uses HTML5 so use the right <!DOCTYPE> • Bootstrap is mobile first or responsive