- This topic is empty.
-
AuthorPosts
-
February 13, 2014 at 4:10 am #162751
lorem
ParticipantHi there,
I got a box that stretches vertically according to the height of a child div, the image should always stay at the bottom of the container e.g.: http://jsfiddle.net/wz3UM/9/
is there a way to keep the minimum height of the container box according to the image within and not to overflow? http://jsfiddle.net/wz3UM/8/
thanks a lot, cheers
February 13, 2014 at 5:40 am #162753Paulie_D
MemberI don’t see how you can affect the height of the parent when the absolutely positioned image is taken out of the flow.
JS/JQ solution required I suspect.
February 13, 2014 at 5:55 am #162754lorem
Participantthanks Paulie,
… just wanted to make sure I don’t miss anything CSSwise before I resort to JS ;)
February 13, 2014 at 6:31 am #162756Paulie_D
MemberUnless there is something one could experiment with
display:table
ordisplay:table-cell
.Hmm…that’s got me thinking.
February 13, 2014 at 7:52 am #162757Paulie_D
MemberOK…not entirely sure why this works but it seems to.
It does require some change in the way the HTML is structured but there is NO absolute positioning involved.
February 13, 2014 at 9:29 am #162764lorem
Participantwow, awesome – very nice! thanks
February 13, 2014 at 9:31 am #162766Paulie_D
MemberThe only think I would say is that I don’t know why this works (or rather I thin I do but I’m not sure I got it right)…I knocked it out in a few minutes so it’s entirely possible that it may not be suitable in all situations AND that it will break at the slightest breath.
Caveat developor :)
February 13, 2014 at 9:47 am #162775lorem
Participantgot one situation where it won’t work …if the text should be on top of the image. going to fiddle around some more
February 13, 2014 at 9:51 am #162777Paulie_D
MemberAh…that wasn’t in the original spec.
If you are trying to flow text around the image that’s at the bottom that’s a whole other ballgame.
February 13, 2014 at 10:19 am #162788lorem
Participantsorry that I was unclear. I meant the box with the text should be on top, not flowing around (http://jsfiddle.net/wz3UM/15/)
February 13, 2014 at 10:25 am #162793Paulie_D
MemberUgh…unless you have a very specific image in mind I would have to say that’s going to provide a poor user experience (UX).
Assuming the image(is) is/are NOT content (if they are, IMO you shouldn’t really be overlaying text) then it makes more sense to use a background image…that’s much easier to position.
February 13, 2014 at 10:42 am #162797lorem
Participanthad this scenario in mind […]
with the background image, the container would’t automatically stretchFebruary 13, 2014 at 11:08 am #162800Paulie_D
MemberNot sure I follow….if the container doesn’t have any contents then it doesn’t need to stretch.
If you need the image to be shown in full, the set a min-height on the container. Is it your thought that this image would, in some way be changing regularly?
February 13, 2014 at 11:25 am #162805lorem
Participant“Is it your thought that this image would, in some way be changing regularly?”
yes, different versions of this kind of setup
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.