280 likes | 385 Views
This comprehensive guide explores essential CSS concepts, including the box model, float configuration, and positioning elements on a webpage. Learn to create responsive column layouts, integrate navigation through lists, and add interactivity to links using pseudo-classes. Delve into advanced selection methods with attribute selectors and pseudo-classes while understanding how to style block, inline, and list-item displays effectively. Additionally, discover structural HTML5 elements to enhance your web design. Empower your front-end skills and build visually appealing layouts.
E N D
6 Layout
Learning Outcomes • Describe & Apply the CSS Box Model • Configure Float with CSS • Designate Positioning with CSS • Create Column Page Layouts using CSS • Create Navigation Utilizing Lists with CSS • Add Interactivity to Links with CSS Pseudo-classes • Utilize Additional HTML5 Structural Elements
Box Model • Describes Rectangular Boxes that Contain Content • Each Block-level Element is Displayed as a Box • Each Content Box can have Margins, Borders, & Padding
Margin Properties • margin: # | % • Shorthand Property Sets All Four Individual Margins
Margin Properties • margin-left | margin-right | margin-top | margin-bottom: # | % • Negative margins can be set to achieve special effects
Positioning Properties • position: type position size • type = static | relative | absolute | fixed • position = top | left | bottom | right • size = height | width
Positioning Properties • div {position:absolute; left:130px; top:100px;}
Positioning Properties • div {position:absolute; left:130px; top:100px;width: 100px;}
Positioning Properties • overflow: visible | hidden | scroll | auto • Defines Situation Where Content Overflows Allotted Space
Positioning Properties • clip: rect(top, right, bottom, left) • Defines Area Through Which Content Can be Viewed
Positioning Properties • visibility: visible | hidden • Specifies Whether an Element is Displayed or Hidden • z-index: auto | # • Specifies an Element’s Stacking Level
Special Box Properties • width: # | % • Sets Horizontal Width of a Containing Box • height: # | % • Sets Vertical Height of a Containing Box • float: left | right | none • Sets Position of an Element to Left/Right of Parent Element • clear: none | left | right | both • Controls Flow of Text Around Floated Elements
Special Box Properties • float & clear
Visual Formatting Model • Three Element Display Type Categories • Block (e.g., Paragraphs) • Contain Inline Boxes that Contain Element Content • Inline • Contain Content within the Block-level Elements • Do not Form New Blocks of Content • List-item • Creates Surrounding Container and List-item Inline Boxes • display: block | inline | list-item | none
List Navigation • Remove List Marker, Underline, Add Padding • Configure List Items for Inline Display #nav ul { list-style-type: none; } #nav a { text-decoration: none; padding-right: 10px; } #nav li { display: inline; } … <div id="nav"> <ul> <li><a href="index.html">Home</a></li> <li><a href="menu.html">Menu</a></li> <li><a href="directions.html">Directions</a></li> <li><a href="contact.html">Contact</a></li> </ul></div>
Advanced Selection • Attribute Selector • Applies to Elements with Specific Attributes • Syntax: a[href] {color: blue;} a:hover img[src=“CODLogo.gif"] {visibility:hidden;}
Advanced Selection • Pseudo-Class Selectors • Select Elements Based on Characteristics Other Than Name • Link Pseudo-Classes • :link • Allow Modification of Style Characteristics for Unvisited Links :link {color: green;} • :visited • Allow Modification of Style Characteristics for Visited Links :visited {color: green;}
Advanced Selection • Pseudo-Class Selectors • Dynamic Pseudo-Classes • Apply Styles to an Element Based on User’s Actions • :hover • Applies Style When User Mouses Over Element • :active • Applies Style When User Activates Element • :focus • Applies Style When Element is Accepting User Input
Advanced Selection • Pseudo-Elements Selectors • Modify Aspects of Document Not Classified by Elements • :first-letter • Apply Style Rules to the First Letter of Any Block-level Element • Initial Capitals • Drop Capitals
Advanced Selection • Pseudo-Element Selectors • :first-letter
Advanced Selection • Pseudo-Element Selectors • :first-line • Apply Style Rules to the First Line of Any Block-level Element
Advanced Selection • Child Selector • > • Apply Style Rules to Child Elements of Any Parent div > blockquote {font-weight: bold;}
Advanced Selection • First Child • :first-child • Apply Style Rules to the First Child Element of a Parent div > p:first-child {font-weight: bold;}
Advanced Selection • Adjacent Sibling • + • Apply Style Rules to • Elements that Share the Same Parent • Are Adjacent in the Code
Structural Elements 5 • <header>…</header> • Contains Headings of a Page, Section, or Article • <hgroup>…</hgroup> • Contains Two or More Heading Elements <header> <hgroup> <h1>Lighthouse Island Bistro</h1> <h2>the best coffee on the coast</h2> </hgroup> </header>
Structural Elements 5 • <nav>…</nav> • Contains a Section of Navigation Links • Block Display • <footer>…</footer> • Contains Footer Content • Block Display • <aside>…</aside> • Contains Sidebar, Note, or Other Tangential Content • Block Display
Structural Elements 5 • <section>…</section> • Contains a “Section”, (e.g., a Chapter or Topic) • Block Display • <article>…</article> • Contains an Independent Entry, (e.g., Blog Posting or Comment) • Block Display • <time>…</time> • Represents Date or Time (e.g., Date Articles or Blogs) • Inline Display