Jump to content

DIV is hanging on minimize.


LeonLatex
Go to solution Solved by LeonLatex,

Recommended Posts

nav_div remains in the same place when I minimize and scale. It should follow the div above, but doesn't. The width and height scale, but it does not move accordingly. What and where is wrong?

CSS:

.big_div {
    margin: auto;
    width: 100%;
    height: 201px;
    padding-top: 0px;
    padding-left: 0px;
    padding-right: 0px;
    font-size: 14pt;
}
.img_div {
    width: 100%;
    height: 203px;
    background: url("../images/logo.png") no-repeat;
    background-size: contain;
}
.nav_div {
    background-color: #ff0000;
    margin: auto;
    width: 100%;
    height: 40px;
    padding-top: 0px;
    padding-left: 0px;
    padding-right: 0px;
    font-size: 13pt;    
    text-align: center;
    vertical-align: middle;
}

HTML:

<div class="big_div"><div class="img_div"></div></div>
<div class="nav_div">
    <a id='nav-hjem' href='<?=$HOST?>index.php' class='w3-bar-item w3-button'>Hjem</a>
    <a id='nav-jeg' href='<?=$HOST?>index.php' class='w3-bar-item w3-button'>Jeg</a>
    <a id='nav-meg' href='<?=$HOST?>index.php' class='w3-bar-item w3-button'>Meg</a>
    <a id='nav-deg href='<?=$HOST?>index.php' class='w3-bar-item w3-button'>Deg</a>
    <a id='nav-du' href='<?=$HOST?>index.php' class='w3-bar-item w3-button'>Du</a>
</div>

Edited by LeonLatex
spelling error
Link to comment
Share on other sites

I don't understand what it is you're saying is wrong.  You should create a fiddle that reproduces the problem and post the link.  Then re-describe the problem, optionally with screenshots if you can't describe it well.

Your HTML is currently invalid due to a missing quote, you should fix that as well.

 

Link to comment
Share on other sites

18 hours ago, kicken said:

I don't understand what it is you're saying is wrong.  You should create a fiddle that reproduces the problem and post the link.  Then re-describe the problem, optionally with screenshots if you can't describe it well.

Your HTML is currently invalid due to a missing quote, you should fix that as well.

 

It is the background image that is scaling, but the two div's is not. I have removed the img_div so I have just big_div and nav_div left. I thought that maybe this would help. I discovered that it is not the nav_div that is not scaling when I minimize the browser window. It doesn't follow the background picture with the logo and graphic. Because the background picture is scaling as it should. The problem occurs when I minimize the browser window, and the two div's are not scaling like the background image. The background image is scaling because of this one:

background: url("../images/topbg.png") no-repeat;
background-size: contain; /*Makes the background scaling.*/ 

First (like in my first posting) I thought that the nav bar was hanging on the same place and the other two div's was scaling. But that wasn't the problem. The problem occurs when the background image is scaling, but the div's is not. How to make this work I don't have a clue, but I hope someone here has and can help. Please, tell me how to solve this problem.

I hope this is enough information when I include the screenshots 😊 The CSS is the same as in my opening posting minus the img_div and I also corrected the quoting that was missing👍

Maximized

Minimized

CSS:

.big_div {
    margin: auto;
    width: 100%;
    height: 203px;
    padding-top: 0px;
    padding-left: 0px;
    padding-right: 0px;
    font-size: 14pt;    
    background: url("../images/topbg.png") no-repeat;
    background-size: contain; /*Makes the background scaling.*/
}
.nav_div {
    background-color: #ff0000;
    margin: auto;
    width: 100%;
    height: 40px;
    padding-top: 0px;
    padding-left: 0px;
    padding-right: 0px;
    font-size: 13pt;    
    text-align: center;
    vertical-align: middle;
}

HTML:

<div class="big_div"></div>
<div class="nav_div">
    <a id="nav-hjem" href="<?=$HOST?>index.php" class="w3-bar-item w3-button">Hjem</a>
    <a id="nav-jeg" href="<?=$HOST?>index.php" class="w3-bar-item w3-button">Jeg</a>
    <a id="nav-meg" href="<?=$HOST?>index.php" class="w3-bar-item w3-button">Meg</a>
    <a id="nav-deg" href="<?=$HOST?>index.php" class="w3-bar-item w3-button">Deg</a>
    <a id="nav-du" href="<?=$HOST?>index.php" class="w3-bar-item w3-button">Du</a>
</div>

Edited by LeonLatex
Link to comment
Share on other sites

  • Solution

I found the solution my self.

- I had to remove the hight on big_div and change it to min-height.

- Set the position property of .nav_div to absolute, and position it at the bottom of .big_div.

- And I had to remove this line: background-size: contain; /*Makes the background scaling.*

 

Both .big_div and .nav_div is scaling in proportion to the background image in .big_div, and .nav_div  stays at the bottom of .big_div when it scales.

Case closed.

Edited by LeonLatex
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.