- This topic is empty.
-
AuthorPosts
-
August 28, 2013 at 7:11 am #148366
Julliet
ParticipantI have one div overlaying another div as follows:
div.container { position: relative; min-height: 100%; margin:0; padding:0; background:url('http://www.scratchprogramming.org/img/book.png'); background-repeat:no-repeat; background-attachment:fixed; background-position: 62% 70%; overflow:hidden; }
div.content { position: absolute; min-height: 100%; margin:0; padding:0; top: 0; left: 0; width:100%; z-index:10; overflow:hidden; }
My html starts out like this:
`<div class="container"> <p> <img src="img/Scratchcat.png" alt="cat" /> </p> </div> <!--container-->` <div class="content">
Now I had to set the height on the cat image really long so that the background image in the container (book.png) will fill the content area. The problem is when testing on different browsers..somtimes the book.png background goes over the content length, leaving a couple of inches extra on the bottom. Is there any way I can make the content and container height the same using css and not having to play around with the image height ? Here is the working example: http://www.scratchprogramming.org Thanks, Julliet
August 28, 2013 at 7:36 am #148376Paulie_D
MemberIs there any way I can make the content and container height the same using css and not having to play around with the image height ?
Not without JS I’m feeling.
At looking at the code (HTML) something just doesn’t sit right…I’m absolutely NOT saying that it’s wrong…it’s just that it seems wrong to me.
I’m honestly not sure what it is…perhaps it’s that the cat image is currently ‘content’ when, to my eyes it really isn’t and could be solved another way.
I’d have to think.
Oh…and you should really look into a ‘Sticky Footer’.
August 28, 2013 at 8:28 am #148385Larsinho
ParticipantMaybe you could wrap the divs styled with ‘display: table;’ and give each inner div ‘display: table-cell;’?
August 28, 2013 at 8:33 am #148386Paulie_D
MemberMaybe you could wrap the divs styled with ‘display: table;’ and give each inner div ‘display: table-cell;
Not sure that will work in this instance…but who knows?
I have an aversion to display:table etc…it just seems wrong these days. I know there is nothing intrinsically wrong with it…it just seems seems to hark back to the old ways of doing things.
August 28, 2013 at 8:50 am #148390Julliet
ParticipantHow would i do it with JS Pauline?
August 28, 2013 at 8:58 am #148392Paulie_D
MemberThat’s Paulie. LOL
With JS/JQ there is a plug-in that determines the height of two divs with the same class, works out which one is tallest and adjusts the height accordingly.
However, I’m thinking that this is a brute force approach to something that should be solvable another way. There should be no need to have the cat image that large when, as far as I can tell, all that is happening is that it’s being moved (by JS anyway?).
I mean it’s not as though it’s required to scale at all.
August 28, 2013 at 9:52 am #148403Julliet
ParticipantI saw this solution, I am playing around with it now : Similar situation…
August 28, 2013 at 11:47 am #148437Julliet
ParticipantThe above solution worked. Thanks for the responses.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.