Solved

HTML automatic div resizing

Posted on 2014-11-05
7
281 Views
Last Modified: 2014-11-06
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;}
0
Comment
Question by:Jalbkay
  • 4
  • 3
7 Comments
 
LVL 2

Expert Comment

by:Amish Sanghrajka
ID: 40423447
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.
0
 

Author Comment

by:Jalbkay
ID: 40423457
Hi Amish,

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

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

Cheers
Chris
0
 
LVL 2

Expert Comment

by:Amish Sanghrajka
ID: 40423512
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.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:Jalbkay
ID: 40423614
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?
0
 
LVL 2

Accepted Solution

by:
Amish Sanghrajka earned 500 total points
ID: 40423664
Hi Chris,

Try this:
<style>
.header {
position: relative;
}
.bg_img {
width: 80%;
z-index: 1;
}
.linkbar{
position: absolute;
bottom: 10px;
height: 64px;
align: center;
text-align: center;
z-index: 2;
width: 100%;
margin: 0 auto;
}
</style>

<body>
<div class="header">
	<center><img src="assets/jpgs/header.jpg" class="bg_img" /></center>
     <div class="linkbar">
     <center>
     <a href="bridge.html" title="Go to the Bridge">
    <img alt="Bridge" height="64" src="assets/mc80cverEJ.png" width="80" longdesc="Go to the Bridge" /></a>
    <a href="intel/intelcon.html" title="Intelligence (Bothan Spy Network?)">
    <img alt="Intel" height="64" src="assets/r2.png" width="64"/></a>
    <a href="recruiting/recmainm.html" title="Recruiting">
    <img alt="Recruiting" height="64" src="assets/recruit.jpg" width="64" /></a>
    <a href="rogue/rogueros.html"></a>&nbsp;
    <a href="rogue/rogueros.html" title="Rogue Squadron">
    <img alt="Rogue Squadron" height="64" src="assets/X-Wing-icon.png" width="64"  /></a>&nbsp;&nbsp;
    <a href="buccaneer/buc.html" title="Buccaneer Squadron">
    <img alt="Buccaneer Squadron" height="64" src="assets/bw.png" width="64" /></a>&nbsp;&nbsp;
    <a href="corsair/corsair.html" title="Corsair Squadron">
    <img alt="Corsair Squadron" height="64" src="assets/aw.png" width="64"/></a>&nbsp;&nbsp;
    <a href="support/rwss.html" title="Renegade Wing Support Squadron">
    <img alt="RSS" height="64" src="assets/y-wing.jpg" width="64"/></a>&nbsp;&nbsp; 
    <a href="tacops/tacops.html" title="Tactical Operations">
    <img alt="Tac Ops" height="64" src="assets/Death_Star.png" width="64" /></a>&nbsp;&nbsp; 
    <a href="lounge/lounge.html" title="The Liberty Lounge"> 
    <img alt="Lounge" height="64" src="assets/bluemilk.jpg" width="64"/></a>&nbsp;
    <a href="library/roguelib.html" title="The Library">
    <img alt="Library" height="64" src="assets/c3po.png" width="64"/></a>
    </center>     
</div>
</div>
</body>

Open in new window


Kind regards,
Amish.
0
 

Author Closing Comment

by:Jalbkay
ID: 40423947
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 :)
0
 
LVL 2

Expert Comment

by:Amish Sanghrajka
ID: 40426693
Glad I could help :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Select only the top record in a left join 13 45
CSS: Making responsive table look nicer 7 31
I am having a  Git   issue 6 42
Connection to multiple databases 13 25
Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question