Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: about positioning and float -property

  1. #1
    Join Date
    Feb 2003

    about positioning and float -property

    I'm having trouble to float an image to the left, and let text elements after that flow around it on the right, without the text elements starting at the left edge of the parent element (thus under the image)?

    The text does render to the right side of the image but the elements are relative to the parent elements' left edge. This makes it impossible to use margin and padding properties to position the text elements relative to the image.

    "display: inline-block;" -rule helps on IE but doesn't do a thing in NS7. Another thing I tried was to wrap the text elements to a container div, but this prevents the text from flowing under the image.


    <img src="foo.jpg" style="float: left;" />
    <p style="padding-left: 10px;"> paragraph </p>

    Here the padding doesn't do anything, because the p element
    starts on the left side of the image.

    Anyone had similar problems? Any thoughts on this?

  2. #2
    Join Date
    Feb 2003
    A little something to clarify what I'm trying to do here:

    +-------+This is
    | image |how it

    ^-- text elements start here

    +-------+....This is
    | image |....how it

    should --^
    start here where
    the image ends
    Last edited by Arkki; 02-28-2003 at 03:16 PM.

  3. #3
    Join Date
    Feb 2003
    Your explanation was elaborate enough,

    ..but we like to see the code as well, so we can see more of the context and you could possibly get better feedback than you asked for.

    So please give a link to the page.html and/or style.css


    ..usually this should work
             .title img {
             .title {
    	padding-left:  imgwidth + paddingLR + borderLR + marginLR px;
    with the html:
    <span class="title"> 
         <img src=".." />
    Last edited by Wisbin; 02-28-2003 at 03:36 PM.
    In the land of plenty, miss pixelperfect is a *****

  4. #4
    Join Date
    Jan 2003
    Atlanta, GA
    <img src="foo.jpg" style="float: left; margin-right:10px" />

  5. #5
    Join Date
    Feb 2003
    Right... I put up a couple of example pages.

    This page has the "display: inline-block;" rule set on all
    h* and p tags,
    and this one has them commented out:
    I also set borders on the elements so you can see how they render. Note that the test1.html works the way I want to on IE but not on NS7. Also note that there are different padding values for h* and p tags so it's not enough to put a margin on the image.

    What I'm looking for is a display property or something that would do the same as the inline-block display rule but on all modern browsers.

    Thanks anyway for the replies. (how pessimistic )
    Last edited by Arkki; 03-01-2003 at 06:15 AM.

  6. #6
    Join Date
    Feb 2003

    Talking try this

    put another container in it: div.text and set the margin-left to the width of the image.

    like this:
    div.photo {
    	padding: 5px;
    	margin-right: 5px;
    	border: 1px solid black;
    div.text {
    	padding: 5px;
    div.footer {
    	clear: both;
    	padding: 5px;
    	border-top: 1px solid black;
    If you put the <div class="text"> over the right-column NS will comply!

    Good luck!
    In the land of plenty, miss pixelperfect is a *****

  7. #7
    Join Date
    Feb 2003
    Yeah.. This again prevents the text from flowing under the image, but I guess that's the only way.


  8. #8
    Join Date
    Nov 2002
    Arkki, what is the reason for you to be using display:inline-block at all?

    Floating an image automatically turns it into block-level anyway, so what's the point of using inline block?

    BTW, inline-block is NOT available in CSS2, only in later still unfinished specs, so any use of it should be considered experimanetal and probably not used on a "real" site.
    // Stefan Huszics

  9. #9
    Join Date
    Feb 2003
    I applied the inline-block rule to the p and h elements which are not floated. The image is the only floated thing here. Check the example urls given earlier (i'll put them back), and you'll see what I mean. I tried everything I could think of, but Inline-block was the only display rule that did what I wanted.

  10. #10
    Join Date
    Nov 2002
    Ok, now I fugured out your problem.

    It depends on you not understanding how float works.
    The text next to a float is positioned by increasing the margin.

    Eg if you have a 100px image left floated, a <p> following will get it's margin set to 100px (if it's lower then this by default).
    Thus you setting 10px margin makes 0 relevance.

    However 10px padding should work.
    The very likely reason it is NOT working for you is becuse your HTML is broken. For starters your testcases don't even include a doctype. This puts modern browsers into "mimic old bugs mode" instead of "standards compliant mode". This usually means your CSS goes to crap.

    Thus start with adding eg
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    at the very top of your pages and then correct errors that show up when you validate your pages at

    Once you do that your problems will llikely go away.

    Last edited by Stefan; 03-01-2003 at 11:29 AM.
    // Stefan Huszics

  11. #11
    Join Date
    Feb 2003
    Heh, well... the documents are totally valid html 4.01 strict and valid css too. Adding a doctype doesn't change the way they're rendered a bit.

    And as you can see I have "padding-left: 10px;" set on all p tags already, and that has "0 relevance" as well.

    Did you look at how the borders of the p elements render in test2.html? If their margins are set to 100px, then why do the borders begin at the left, where the image begins? If an element has a margin of 100px, shouldn't the element's left edge be 100 pixels away from the left edge?

    Anyway, don't bother to look into this anymore. I give in to the fact that there's no way to make this work the way I want it to.

  12. #12
    Join Date
    Jan 2003
    Atlanta, GA
    Originally posted by Arkki
    Adding a doctype doesn't change the way they're rendered a bit.
    Adding a doctype DOES make a lot of difference. It toggles browsers (all browsers including IE, NS, opera etc) into buggy/compliant modes. Believe me, I have learnt it hard way.

  13. #13
    Join Date
    Feb 2003
    Yeah I know but it doesn't change it in this case.

  14. #14
    Join Date
    Nov 2002
    Hampshire, England

    This won't help you much, but it might help you to understand what's happening.

    This is a quote from Eric Meyers book:

    "Although floating elements are removed from the normal flow of the document, they do affect the layout of content within the document. This is effectively done by increasing the padding within any following elements on those lines which are next to a floating element. However this means that the backgrounds and borders of any element will extend "underneath" the floated element, and possibly past the other side of the floated element. This behaviour ensures that all element boxes will remain rectangular, but it can lead to unwanted effects. "

    Therefore to effect any change on your paragraphs you will need to make padding that is at least as wide as your image before any effect will show. However this will also stop the text flowing under the image as it will now have padding that is wider than the image.

    I think your only solution is to forget about text wrapping underneath the image (especially if you want borders around it) and set the headings and paragraphs to have a left margin of say 170px then they will keep the format that you have set with the padding. Then you can get rid of those inline blocks and have a page that works in all compliant browsers.

    (If you want text (without borders) to flow to the side and underneath your image you will just have to do without the indentation on the headings.)


  15. #15
    Join Date
    Feb 2003
    Thanks. I resorted to the solution by wisbin (wrapper div with a margin). It's good to know it can't be done, and thus be able to finally sleep my nights at peace
    You saved me from a lot of nightmares with evil block elements floating around.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.12013 seconds
  • Memory Usage 3,002KB
  • Queries Executed 13 (?)
More Information
Template Usage (37):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (15)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (15)postbit
  • (15)postbit_onlinestatus
  • (15)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates