• Hello again, Im a little stumped with positioning and floating divs.

    What I need to have is a container div with some content in it, and then another inner div/img in the bottom right hand corner. The container div has a variable height and any text must wrap around the div/img. I’ve posted the basic code below, I basically want to float the image to the right and align it with the bottom of the container div but this isn’t as simple as I first thought, they should really implement a ‘sink’. Hopefully someone can help. I’ve tried many methods and actually got it in the right spot before but with text not wrapping around it.

    <div class="container" width="50%" height="50%">
    <div class="art-image" width="75px" height="75px">
     <img src="image.jpg" width="75px" height="75px">
    </div>
    Content to wrap around image here
    </div>
Viewing 14 replies - 1 through 14 (of 14 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Try

    .art-image {
     position: relative;
    }
    
    .art-image img {
     position: absolute;
     bottom: 0;
     right: 0;
    }

    https://www.w3schools.com/Css/css_positioning.asp

    Hi Toby,

    Do you have a link to the example? If not the code below maybe what your after?

    .art-image {
    float:right
    position:relative;
    bottom:0
    }
    Thread Starter tobybowes

    (@tobybowes)

    Sorry neither of them worked, just quickly typed out a dummy code and uploaded it on the link below. The blue div is currently float right and wrapping text, but I need to move it to the bottom right corner remembering the height is variable.

    https://www.tobybowes.karoo.net/test/tester.html

    I can implement any further ideas and re upload to show the results if working or not.

    Thanks for the help so far anyways!
    James (tobybowes)

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Try

    .container {
     position: relative;
    }
    
    .art-image {
     position: absolute;
     bottom: 0;
     right: 0;
    }

    Thread Starter tobybowes

    (@tobybowes)

    Thats got the art-image to the right spot again, but it doesn’t wrap the text regardless of wether I leave the float element in or not (I think the position element just overwrites it if its left in). Re-uploaded results.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Wrap your text in a paragraph element, then move the <div class="art-image"> below the paragraph.
    E.g

    <div class="container">
    <p>
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    Content to wrap around image here
    </p>
    
    <div class="art-image">
    IMAGE HERE
    </div></div>

    Then remove all positioning on <div class="art-image">, but keep the float right.

    Then add overflow: hidden; to <div class="container">
    E.g

    .container {
     overflow: hidden;
    }

    Thread Starter tobybowes

    (@tobybowes)

    Its now aligned below the paragraph not wrapping in the corner. Re-uploaded

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Put

    <div class="art-image">
    IMAGE HERE
    </div>

    Wherever you want inside the paragraph.

    Thread Starter tobybowes

    (@tobybowes)

    That cuts the paragraph and inserts it in the top right on the next part again. Re-uploaded

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Move it around in the paragraph until you get your correct position.

    Thread Starter tobybowes

    (@tobybowes)

    Thanks for the help but that doesn’t work, placing it at the beginning puts it in the top-right and wraps the full paragraph, placing it in the middle puts the first part of the paragraph above and then wraps the remaining with it in the top-right, and placing it at the end but still inside the paragraph places it below the paragraph again in the top right.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    I don’t think what you’re asking is possible, to seek better advice you should try a forum that specialises in CSS
    https://csscreator.com/forum

    Thread Starter tobybowes

    (@tobybowes)

    During my hunt for an answer to this ive heard alot about negative margins or applying js to the art-image to send it to the bottom but neither have been explained from what ive found. The positioning that you showed me first is the closest I’ve got to an answer but with no wrapping it again is no good.

    Thanks for all your help I shall pop over there and see if they can help

    Thread Starter tobybowes

    (@tobybowes)

    So’s not to leave this thread unanswered, I got the desired effect answered over at sitepoint, its not perfect but does the job.

    https://www.sitepoint.com/forums/showthread.php?883631-CSS-Floating-Divs-to-the-bottom-inside-a-Div

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘CSS Floating Divs to the bottom inside a Div’ is closed to new replies.