Link to home
Start Free TrialLog in
Avatar of Jalbkay
JalbkayFlag for Australia

asked on

HTML automatic div resizing

G'day All,

I'd like to get a <div> to resize automatically, the same as the background in the following snippet, so that the linkbar div stays at the bottom of the header and doesn't sit halfway down the page as the browser screen narrows.   Any and all help greatly appreciated.


.header {
background-image: url(assets/jpgs/header.jpg);
background-repeat:no-repeat;
background-position:center top;
background-attachment:fixed;
-o-background-size: 80% auto, auto;
-moz-background-size: 80% auto, auto;
-webkit-background-size: 80% auto, auto;
background-size: 80% auto, auto;
}
.linkbar {style: height: 64px;
      align: center;
      text-align: center;}
Avatar of Amish Sanghrajka
Amish Sanghrajka

Hi,

Have you got an example of the page I can look at to get a clearer image of what you want it to do?

Kind regards,
Amish.
Avatar of Jalbkay

ASKER

Hi Amish,

Sure:  http://renegadewing.com/renegade_wing.html

Just resize your browser and you will see what I mean.

Cheers
Chris
Hi Chris,

There are two options I can think of here. First one is to have a fixed size background such as is on the index page of the site. Alternatively if you want the background image to shrink when the window is resized use embedded <div> tags and set the background in the parent <div>.

Example:
<style>
.header {
position: relative;
background-image: url(assets/jpgs/header.jpg);
background-repeat:no-repeat;
background-position:center top;
background-attachment:fixed;
-o-background-size: 80% auto, auto;
-moz-background-size: 80% auto, auto;
-webkit-background-size: 80% auto, auto;
background-size: 80% auto, auto;
}
.linkbar{
position: absolute;
bottom: 10px;
height: 64px;
align: center;
text-align: center;
}
</style>

<body>
<div class="header">
     <div class="linkbar">
     </div>
</div>
</body>

Open in new window


That will keep the linkbar 10px above the bottom of the background image. If you also want to look at resizing those link images on a browser resize then I would recommend looking into jQuery.

Let me know if you need a bit more clarification on any of this.

Kind regards,
Amish.
Avatar of Jalbkay

ASKER

Hi Amish...
Not really the desired result:
http://renegadewing.com/css_test.html
The header div doesn't resize in any way and the linkbar is unuseable as the header div has no sizing.  Is there not a way to make the div resize with the background?
ASKER CERTIFIED SOLUTION
Avatar of Amish Sanghrajka
Amish Sanghrajka

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jalbkay

ASKER

Once I was able to make it clear what I was trying to do Amish nailed it!  And I've learned something new to boot :)
Glad I could help :)