Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> A Demonstration Of Floats, Clears And Absolute Positions, See the differences here...
jlhaslip
post Sep 23 2007, 07:03 AM
Post #1


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,882
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



Got working on something the other day and came up with this small demonstration on the differences between several techniques using the same html code, but different CSS to position a block of four thumbnail images approximately the same ( well, similar at least ) onto a page and the resultant differences in the effect of the techniques. Have a look: http://www.jlhaslip.trap17.com/samples/mis...ions/index.html

The first one uses floats to group the images into a fixed width block and then uses absolute positioning of the wrapper div to space them off the left hand side and down a little from the top of the page. That last paragraph actually follows the code for the Image block if you do a view > source, but the absolute positioning of the group of pictures removes the block from the normal flow of the page, which allows the paragraph to slide up. Might be what you want, but re-sizing the viewport will alter things . Try it.

The second one uses absolute positioning of each image and a percentage of the viewport to place the same four images into pretty much the same place on the display... well, my display at least... and therein lies a problem with position:absolute and percentages for layout. Resizing the Browser viewport changes stuff, majorly... Oh, and because the Image Blocks are declared to be 100% width of the viewport, and because of the manner in which the browser places the absolutely positioned div's onto the page {after} positioning the rest of the page, the image block is effectively a 'layer' over top of the third and fourth links, so you can't click them because the Browser ties to click the Image block layer, but there are no links there. The links are under the transparent Image block. Click the first link to access links three and four.

The next page uses Floats to group the Image and margins to space the grouped images off the left hand side approximately the same as the previous pages. notice how the trailing paragraph is displayed beside the group of Images? This is a result of using Float to position the grouped pictures. The paragraph will 'wrap' the images, taking up the next available spot on the display, next to the images. This is a common technique used in layouts.

Lastly, if you don't want the 'wrapped' look, then 'clear' the block of images by using 'clear:both' on the trailing paragraph. Options for the clear are left : right and both, depending on the presentation you want to provide for the page.

Hope this helps you understand that css is a handy tool for laying out your pages, and does a good job of it, but be careful how you go about it. There is usually more than one method that you have available to create the same/similar look to a page, and each of them has various side effects. The method you choose might be the right one, but it might not be...
Go to the top of the page
 
+Quote Post
suberatu
post Oct 3 2007, 08:44 PM
Post #2


Advanced Member
*******

Group: Members
Posts: 132
Joined: 23-September 07
Member No.: 50,511



Very nice. I'm not too much into CSS, but I can appreciate a demonstration and explanation that is as clear and easy-to-understand as yours. Even though I'm not strong with CSS, I was able to follow most of what you said, or at the very least the concept, if not the actual coding.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Teamspeak 2 Vs Ventrilo(10)
  2. Is There A Way To Make "absolute Links"?(6)
  3. Disgusting(6)
  4. Base Tag(2)
  5. Inspiron/latitude/precision Quality Differences?(6)
  6. Police Assault On On Peaceful Demonstration(3)
  7. Server Absolute Referencing(4)
  8. Pentium M Differences: 1.73ghz? 1.86? 2.1?(2)
  9. Those Absolute Essentials(0)
  10. Podcasting For The Absolute Newb(5)
  11. Php Version Differences? Or Not?(5)
  12. Script Won't Work At Trap17 -- Version Differences?(12)
  13. Server Differences?(3)
  14. Oracle And Cisco, What Are These,(4)
  15. Free Web Hosting: (absolute)(1)
  1. What Is Absolute Zero?(9)
  2. Differences Of Squares(10)
  3. Free Web Hosting: (absolute)(1)
  4. Compare Two Vars And Highlight The Differences(7)
  5. Ie And Firefox Layout Differences(10)
  6. 3d Landscape In Swishmax (flash)(1)
  7. Absolute Value In C(4)
  8. Differences Between Trap17 & Qupis(3)
  9. Does Duplicate Content Affects Search Engine Positions ?(1)
  10. Jsp Versus Php(1)
  11. Free Web Hosting: (absolute Zer0) [screened] [approved](2)
  12. Age Differences Of Friends(8)
  13. What Will Be The Side Effects If We Can Move And Think On The Speed Of Light(2)


 



- Lo-Fi Version Time is now: 26th July 2008 - 02:51 PM