Learning Web Design: Adding Structure with CSS using Positioning, Floating, & Clearing

سعر الاسهم اليوم مباشر Positioning, Floating, and Clearing are three fundamental pieces you need in order to add visual structure to your site. This is the second post of a two part series discussing how to add structure to your site with CSS. The first post can be found here.

منتدي البورصه السعوديه

Positioning

Default Positioning

http://providencecarey.com/?finse=forex-bank-partille-%C3%B6ppettider&5de=2b forex bank partille öppettider By default every element is set to position: static;. In CSS-land this stupidly means your element hasn't been positioned. Maybe it's better to think of it as meaning that you just haven't applied a non-default position yet. Why is that important? - because your element needs to be positioned to do almost anything important with it (e.g., adding width, height, or moving left, right, up, or down).

stefania conti forex CSS Position: static (default)

ماهو افضل بنك لتداول الاسهم Note: The only position values we'll deal with are relative & absolute. This should make it easy to remember. You can check out the other possible values here.

Relative vs. Absolute Positioning

http://theshopsonelpaseo.com/?syzen=%D8%AA%D8%AF%D8%A7%D9%88%D9%84-%D8%A7%D9%84%D8%A7%D8%B3%D9%87%D9%85-%D8%A7%D9%84%D8%B3%D8%B9%D9%88%D8%AF%D9%8A%D8%A9-%D8%AA%D8%AF%D8%A7%D9%88%D9%84&55c=af تداول الاسهم السعودية تداول Here are three rules to remember with positioning:

  1. "relative" means "relative to where the element lies naturally in the document flow"
  2. "absolute" means any CSS values given to top, right, bottom, & left will be made "from the bounds of the closest positioned parent
  3. setting position: absolute removes the element from the document flow causing subsequent content to take its place.

تداول مباشر مجانا Once you've applied a relative or absolute position value, you can begin moving it around using the CSS top, left, right, & bottom.

http://www.homebusiness-at.com/?kampys=kishore-forex-trading kishore forex trading CSS Position: relativeCSS Position: absolute

تداول وطرح الاسهم In the left example applying a relative position, with top & left offset values causes it to move 20px from the top and from the right of its natural position (without breaking the layout of surrounding elements).

http://www.neweradentalsociety.org/?biter=%D9%85%D9%88%D8%B9%D8%AF-%D8%AA%D8%AF%D8%A7%D9%88%D9%84-%D8%A7%D8%B3%D9%87%D9%85-%D8%A7%D9%84%D8%AD%D9%85%D8%A7%D8%AF%D9%8A&765=31 موعد تداول اسهم الحمادي In the right example applying an absolute position causes img #3 to move in to the left taking the place of img #2 which is now positioned 20px from the top and left of the closest positioned parent (which we're assuming is either a relatively positioned div or the body).

http://frontcivictgn.org/?gondon=%D8%AF%D9%8A%D9%84%D9%89-%D9%81%D9%88%D8%B1%D9%83%D8%B3&54a=06 ديلى فوركس If you're still having trouble with this concept, I found a pretty good tutorial here: Learn CSS Positioning in Ten Steps.

Floating

http://zlatni-presek.com/?w=%D8%A7%D8%B1%D9%8A%D8%AF-%D8%A7%D9%86%D8%A7-%D8%A7%D8%B4%D8%AA%D8%B1%D9%8A-%D8%A7%D8%B3%D9%87%D9%85-%D8%B3%D9%88%D9%82-%D8%A7%D9%84%D8%A7%D9%88%D8%B1%D8%A7%D9%82-%D8%A7%D9%84%D9%85%D8%A7%D9%84%D9%8A%D9%87-%D8%A7%D9%84%D9%83%D9%88%D9%8A%D8%AA%D9%8A&060=11 اريد انا اشتري اسهم سوق الاوراق الماليه الكويتي The idea of floating is directly related to an element's display value (i.e., inline or block). Block level elements (e.g., div, p, ul, li) naturally occupy 100% of the width in the document flow.

http://hinghamgirlscouts.org/?kiopd=%D9%85%D8%AA%D9%8A-%D9%8A%D9%85%D9%83%D9%86-%D8%A8%D9%8A%D8%B9-%D8%A7%D9%84%D8%A7%D8%B3%D9%87%D9%85 متي يمكن بيع الاسهم CSS:

المتاجرة بسبائك الذهب div.block_example ul { list-style: none; } div.block_example li { border: 1px solid red; }

http://www.schodyprudlik.com.pl/?safeno=trader-broker&638=00 trader broker HTML:

http://quiltshopgal.com/?lester=%D8%A7%D8%B3%D8%B9%D8%A7%D8%B1-%D8%A7%D8%B3%D9%87%D9%85-%D8%A7%D9%84%D8%B4%D8%B1%D9%83%D8%A7%D8%AA-%D8%A7%D9%84%D8%B3%D8%B9%D9%88%D8%AF%D9%8A%D8%A9&918=31 اسعار اسهم الشركات السعودية <div class="block_example"> <ul> <li>item 1 isn't floated</li> <li>item 2 isn't floated</li> <li>item 3 isn't floated</li> </ul> </div>

http://insprs.org/?ryops=%D8%B3%D8%B9%D8%B1-%D8%A7%D8%B3%D9%87%D9%85-%D8%A8%D9%86%D9%83-%D8%A7%D9%84%D8%A7%D9%87%D9%84%D9%8A&dc8=20 سعر اسهم بنك الاهلي Example:

  • item 1 isn't floated
  • item 2 isn't floated
  • item 3 isn't floated

تحميل برنامج فوركس Conversely, inline elements only take up the width of the element (e.g., img, span).

forex omvandla pengar CSS:

div.span_example { background: #ccc; } div.span_example span { background: #aaa; }

HTML:

<div class="span_example">
  <span>this is a span</span>
  <span>this is a span</span>
  <span>this is a span</span>
</div>

Example:

this is a spanthis is a spanthis is a spanthis is a span

Floating a block element basically forces it to shrink back to only the width it needs. The "width it needs" depends on either an explicit width set or the width of its contents. Floating also causes the following elements to wrap around the floated element, causing them to appear as if they were inline. Here is the list item example above with each item floated left.

CSS:

.float_left { float: left; }

HTML:

<div class="block_example">
  <ul>
    <li class="float_left">item 1 is floated left</li>
    <li class="float_left">item 2 is floated left</li>
    <li class="float_left">item 3 is floated left</li>
  </ul>
</div>

Example:

  • item 1 is floated left
  • item 2 is floated left
  • item 3 is floated left

The options for the float property are left, right, none (default), & inherit. Floating an item to the right simply aligns the floated element to the right-most boundary of its containing element.

CSS:

.float_right { float: right; }

HTML:

<div class="block_example">
  <ul>
    <li class="float_right">item 1 is floated right</li>
    <li class="float_right">item 2 is floated right</li>
    <li class="float_right">item 3 is floated right</li>
  </ul>
</div>

Example:

  • item 1 is floated right
  • item 2 is floated right
  • item 3 is floated right

Clearing

"Elements after the floating element will flow around it. To avoid this, use the clear property." - http://www.w3schools.com/css/css_float.asp

Think of clearing as a way to "break out of the float". Clearing allows an element to avoid the wrap-around caused by a floated element before it.

Here is the floated list-item example with one cleared element.

CSS:

.float_left { float: left; }
.clear_left { clear: left; }

HTML:

<div class="block_example">
  <ul>
    <li class="float_left">item 1 is floated left</li>
    <li class="float_left">item 2 is floated left</li>
    <li class="float_left clear_left">item 3 is floated left</li>
  </ul>
</div>

Example:

  • item 1 is floated left
  • item 2 is floated left
  • item 3 is floated left and cleared left

The options for the clear property are left, right, both, none (default), & inherit.

The concept of clearing either left or right means specifically that an element set to clear left will get rendered on a new line after any items before it that are set to float left. Conversely, an element set to clear right will get rendered on a new line after any items before it that are set to float right. You may have guessed that an element set to clear both will get rendered on a new line after elements that are floated either left or right. See the illustration below for an example.

CSS Clear Both

CSS Clear Both

In Closing

Understanding these three concepts of positioning, floating, and clearing is essential for applying structure to your website. You can find additional resources on a presentation I made for my Web Design 1 class at Parsons - Adding Structure with CSS.

If you have any more questions or need clarification on any of these concepts please let me know and I'll be happy to help.

Thanks for reading!

Related Books

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>