70 likes | 202 Vues
Enhance your web design skills with essential tips for working with divs and layouts. Learn how to center elements using "margin: auto" for fluid designs, and effectively clear floats to prevent overlapping issues. Discover how to construct grid-like layouts by calculating sizes and margins. Gain insights into utilizing stylesheets in your HTML to organize style instructions either internally or through external files. Master ID and class styling for uniform design across your webpage, ensuring your styles are consistently applied to the correct elements.
E N D
ITP 104 More divs and Layouts
Some General <div> Layout Tips • Centering: • Use a style instruction of "margin: auto" in conjunction with a DEFINED width to make a div/container be "centered" within its area.
Some General <div> Layout Tips • Clearing floats: • If you are having problems with floating elements overlapping or overrunning elements, stop and think if you need a clear:both to divide up "sections" of your page. • Clear "resets" float settings, which basically means items after a "clear:both" will wait until all current floating elements have finished/closed before the new divs appear/are laid out.
Some General <div> Layout Tips • Building "grid"-like layouts: • If you want to lay out lots of boxes evenly spaced out like a grid, you need to calculate their sizes AND their margins/paddings, then set an outer box that is that total.
Stylesheets • Stylesheets are section of html where you can save one or more style instructions under one "name". • They are located either in the "head" of a page (which is called an internal stylesheet), or in a separate file that is "linked" into a page (which is called an external stylesheet).
Stylesheets • Stylesheets start and stop with "style" tags. • Each "style" in a stylesheet starts with a name • the content of that style is defined by { } brackets.
Stylesheets – Style Types • ID: • In your stylesheet, store your style instructions under an ID (pound sign) name in the format #name ... such as #outercontainer • The object in your page with that id (such as div id="outercontainer") will automatically acquire those style settings • Class: • In your stylesheet, store your style settings under a class (period) name in the format .name ... such as .headline • Any object in the page that is set to that class will acquire those style properties, such as span class="headline" • Tag: • In your stylesheet, store your style instructions under an html tag name • ALL objects of that type in the page (img for images, div for div boxes, a for hyperlinks, etc.) will have those style properties as their new defaults