190 likes | 413 Views
CSS Basics. Hide, Move, or Tweak (Almost) Anything in Your Community Sites. Tools We’re going to use. FireFox browser FireBug Chrome browser. Objectives. What is CSS & how it works Live examples Introduction to helpful tools Your questions and real-life examples. Methodology. YES
E N D
CSS Basics Hide, Move, or Tweak (Almost) Anything in Your Community Sites
Tools We’re going to use • FireFox browser • FireBug • Chrome browser
Objectives • What is CSS & how it works • Live examples • Introduction to helpful tools • Your questions and real-life examples
Methodology YES • Getting things done • Good enough • Fundamentals and building blocks NO • Reinventing the wheel • Pixel-perfect across every browser ever invented • Definitive resource for all CSS
What is CSS? • #Logo{ • display:none; • } • .breadcrumb{ • float:left; • } • .MPContentAreaHome #PrinterFriendly{ • display:none; • } • .HLLandingControlulli{ • border-bottom: none;list-style-type: disc;margin-bottom: 0px;padding-bottom: 0px; • } Cascading Style Sheets What does CSS do? Tells the web browser how the web page should look.
HTML Anatomy & Terminology HTML STUFF... <body> <h1>First heading</h1> <p class=“okay”>My first paragraph.</p> <div> <p id=“best”>another paragraph</p> <p class=“okay”> another paragraph </p> <p> another paragraph </p> <p> another paragraph </p> </div> </body> ...HTML STUFF • Elements<body> <p> <div> <h1> • Tags<p>……</p> • Attributes<p id=“best”> • NestingParent, child, sibling, descendent
CSS Anatomy & Terminology • div{ • Padding:10px 5px; • } • p{ • Color: #f00; • font-size: 16px; • } • .HLLandingControlulli { • border-bottom: none;list-style-type: disc;margin-bottom: 0px;padding-bottom: 0px; • }
The Box Model Margin • Every HTML element on the web is a rectangular box. • Components of a box: • Content • Padding • Border • Margin • Different elements have different default box styles. • CSS let’s us control the characteristics of each box. Border Padding Content
Selectors From general to specific • Tags – p – selects all elements with this tag. • Class– .className – selects all elements with this class. • ID – #idName – selects element with this ID. Combine the items above to select descendents HTML STUFF... <body> <h1>First heading</h1> <p class=“ok”>My first paragraph.</p> <div> <p id=“best” class=“ok”>paragraph</p> <p class=“ok”>paragraph </p> <p>paragraph </p> <p>paragraph </p> </div> </body> ...HTML STUFF
Tools to help you get things done • FireFox • FireBug • Chrome • Notepad (or text editor or choice) • JSFiddle
Keeping things organized • /*=== GENERAL === */ • #Logo{ • display:none; • } • .breadcrumb{ • float:left; • } • /*=== REMOVE PRINT FROM HOMEPAGE === */ • .MPContentAreaHome #PrinterFriendly{ • display:none; • } • /*=== REMOVE HOEMPAGE LIST FORMAT=== */ • .HLLandingControlulli{ • border-bottom: none;list-style-type: disc;margin-bottom: 0px;padding-bottom: 0px; • } • Comment everything Not messing up your site • Make a backup of your site and CSS for some trial and error.
Hiding elements <p> Element 1 </p> • Most commonly requested and used CSS trick in the HUG discussions. • Easy to do. #Element2{ display:none; } <p id=“Element2”> Element 2 </p> <p> Element 3 </p> <p> Element 4 </p> <p> Element 1 </p> <p> Element 3 </p> <p> Element 4 </p>
Moving elementson the page 20px • Increasing the padding or margin between itemsto nudge elements. • Set the CSS Position property and then specify the elements new location. • P{ • position:relative; • left:20px; • top:20px; • } 20px
Overriding existing CSS Tweaking elements • Font (font-family) • Size (font-size) • Bold (font-weight) • Spacing (line-height) • Case (text-transform) • Color (color) Sedutperspiciatisundeomnisistenatus error sit voluptatemaccusantiumdoloremquelaudantium, totamremaperiam, eaqueipsa quae abilloinventoreVERITATIS ET QUASI ARCHITECTO dicta suntexplicabo. • Use!important to override inline CSS style.
Q&A and real-life examples • More examples? • What would you like to learn more about? • Is there something specific on your site you’d like to change?
Resources & tools • CSS & HTML fundamentalslearn.shayhowe.com/html-css/ • Mozilla CSS schoolhttps://developer.mozilla.org/en-US/learn/css • JSFiddle to test out CSSwww.jsfiddle.net • Create CSS buttonswww.cssbuttongenerator.com • FireBughttp://getfirebug.com/ • Other HL sitesUse FireBug-like tools to see under the hood of other websites • HUGhttp://hug.higherlogic.com/Home/ • Me (Justin Prevatte)Email or Message me on HUG if you have a question and I’ll do my best to help out.
Justin Prevatte jnprevatte@gmail.com Contact Info HUG Profile Link