0

Hi all...
i have a problem with my fixed header. when i zoom in or resize the browser, some menu in my header losts/hidden i don't know where..

so this is my code :

    <div id="header">
    <ul>
        <li>Menu 1</li>
        <li>Menu 2</li>
        <li>Menu 3</li>
        <li>Menu 4</li>
     </ul>
</div>

css :

body{
     min-height:1000px;
}
#header{
     position: fixed;
     margin:30px;
}
#header ul{
     display:block;
}
#header ul li{
     float:left;
     list-style-type:none;
     width:110px;
     text-align:center;
     line-height:30px;
     padding-bottom:3px;
     background: #ccc;
}

demo : http://jsfiddle.net/YgvND/1/

I need javascript program to controls css position. My purpose when at zoom in, zoom out or resize the browser so css header position will change into "ABSOLUTE".

sorry on my language. x)
Anyone can help me....
thx..

1
  • What browser is this happening with? I'm not seeing anything wrong with your fiddle in Chrome. Commented Sep 26, 2012 at 19:37

2 Answers 2

0

i recommend you to use jquery. a good approach to check for resulution changes is described in here

Sign up to request clarification or add additional context in comments.

Comments

0

I'm not totally sure I'm understanding your question, but I'll give it a go. It seems to me like you want to position the #header div as absolute when the page is resized. So, use jQuery to look for window resize.

This might be overkill in your situation. This will bind whatever css changes to the #header div as soon as the page is done being resized.

$(window).resize(function() {
  if (this.resizeTO) clearTimeout(this.resizeTO);
  this.resizeTO = setTimeout(function() {
      $(this).trigger('resizeEnd');
  }, 500);
});

$(window).bind('resizeEnd', function() {
  var header = $("#header");
  header.css({
      position: "absolute",
      top: "0px",
      left: "0px"
  });
});

Here's a demo.

1 Comment

Hi SeasonEnds its work.. thx.. but when window back to normal css position still in "ABSOLUTE" not in fixed again??

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.