elmmm
elmmm

Reputation: 43

margin-top for this div does not work in Firefox

I have divided my layout into divs, and within the div="content" area I have a table and a filter option which need to be positioned. I'm trying to insert some margin between the filter option area and the navigation bar. This looks fine in Chrome but in Mozilla Firefox the filter options appear way below than they should.

This is my code and how it looks at the moment:

http://jsfiddle.net/elmiri/5mXJ7/ if you open this link in Chrome the filter option looks fine however in Mozilla it looks really bad. Here is all of my code:

<div id="header">
<h1>LOGO</h1>
</div>

<div id="navigation">
<ul>
    <li><a href="">Home</a></li> 
    <li><a href="">Test</a>
    <li><a href="">Test</a>
    <li><a href="">Test</a> 
    <li><a href="">Activity Feed</a> 
    <li><a href="">Stats</a> 
    <li><a href="">Contact Us</a> 
    <li><a href="http://localhost/playtime/itms/Users/users.php">Users</a> 
    <li><a href="">My account</a> 
    </ul>

</div>
</body>
</html>
<div id="personalised">
<p>Hello, </p>
</div>
<div id="content">
<form id="form1" method="get" action="">
<div id= "filter">
  <label for="column">Select client type:</label>
  <select name="column" id="column">
    <option selected>Key</option>
    <option >Norm</option>
    <option >Onb</option>
  </select>
  <input type="submit" name="change" id="change" value="Filter">
  <input type="submit" name="Remove" id="Remove" value="Show all">
  </div>
<table>
  <tr>
    <th scope="col">Client name</th>
    <th scope="col">Client type</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
  </tr>
    <tr>
    <td>Client2</td>
    <td>KEY</td>
    <td><a href="#" onclick="newWindow('update_clients.php?client_id=3', 800, 800)">EDIT</a></td>
    <td><a href="delete_clients.php?client_id=3">DELETE</a></td>
  </tr>
    <tr>
    <td>Client3</td>
    <td>KEY</td>
    <td><a href="#" onclick="newWindow('update_clients.php?client_id=5', 800, 800)">EDIT</a></td>
    <td><a href="delete_clients.php?client_id=5">DELETE</a></td>
  </tr>
    <tr>
    <td>client4</td>
    <td>NORM</td>
    <td><a href="#" onclick="newWindow('update_clients.php?client_id=7', 800, 800)">EDIT</a></td>
    <td><a href="delete_clients.php?client_id=7">DELETE</a></td>
  </tr>
    <tr>
    <td>client4</td>
    <td>ONB</td>
    <td><a href="#" onclick="newWindow('update_clients.php?client_id=8', 800, 800)">EDIT</a></td>
    <td><a href="delete_clients.php?client_id=8">DELETE</a></td>
  </tr>
    <tr>
    <td>client100</td>
    <td>Key</td>
    <td><a href="#" onclick="newWindow('update_clients.php?client_id=13', 800, 800)">EDIT</a></td>
    <td><a href="delete_clients.php?client_id=13">DELETE</a></td>
  </tr>
  </table>
</div>

This is the part of the code that positions the filter option:

<div id= "filter">
  <label for="column">Select client type:</label>
  <select name="column" id="column">
    <option <?php if ($col == 'Key') echo 'selected'; ?>>Key</option>
    <option <?php if ($col == 'Norm') echo 'selected'; ?>>Norm</option>
    <option <?php if ($col == 'Onb') echo 'selected'; ?>>Onb</option>
  </select>
  <input type="submit" name="change" id="change" value="Filter">
  <input type="submit" name="Remove" id="Remove" value="Show all">
  </div>

the css code:

#filter {
float:right;
margin-top: 2%;
}

THIS filter div is within the Content div so I'm not sure if that's causing problem. I tried to set margin-top to 20 px and it still did not work in Firefox. Would be grateful if someone helped me put a gap between the navigation bar and the filter option so that it looks fine both in Chrome and Mozilla. Thank you

Upvotes: 0

Views: 5666

Answers (1)

xpy
xpy

Reputation: 5621

That's because the margin-top if set in a percentage it is proportional to the element's parent width and not height as one would normally expect. Margin on MDN.

Upvotes: 2

Related Questions