4

I have a web page built in angularjs .

<html>
<head></head>
<body ng-app="app1" ng-controller = "ctrl1">

<header></header>

<div ng-view></div>

<footer></footer>

</body>
</html>

Here the header and footer is always fixed, but in content section when I am doing routing and in one of the view I have header which I always want to be fixed.

The problem is when use position:fixed for that content header and while moving the scroll of main page , the content below the header seems to move upwards.

so my question is how can I create that header in such a way that while scrolling down the content section or main section the header should always be fixed.enter image description here

Any help is appreciated !!!

Thanks

Grzegorz
  • 3,207
  • 3
  • 20
  • 43
shreyansh
  • 1,637
  • 4
  • 26
  • 46

3 Answers3

1

WHat you need to do is add a padding-top to you content that is equal to the height of your header. That way your content will never scroll up below the header

.content-header {
height: 30px;
position: absolute;
top: 0px;
}
.content-container {
padding-top: 30px;
overflow: scroll;
position: relative;
}
nikjohn
  • 20,026
  • 14
  • 50
  • 86
0

Use overflow: scroll; for that div.

<div class="content" ng-view></data>

.content {
    width: 150px;
    height: 150px;
    overflow: scroll;
}

Refer : http://www.w3schools.com/cssref/pr_pos_overflow.asp

Snopzer
  • 1,602
  • 19
  • 31
0

You could use bootstrap to ease your task. Kindly refer to : https://getbootstrap.com/examples/navbar-fixed-top/

Hope this helps you.

Denver Gomes
  • 44
  • 1
  • 12