Position fixed css adding in body tag in angular material
Asked Answered
B

2

17

I'm facing some issues with position: fixed; width: 100%; top: 0px; for md-select md-autocomplete if I use them in some fixed. I face this issue with angular material for almost all the md-select options. It's adding up the CSS attributes dynamically to the body section.

position: fixed; width: 100%; top: 0px; and scrollY.

index.html

<header class="container-fluid" id='headerControl' ng-cloak ng-controller = 'headerControl as ctrl'>
  <div layout="row">
    <div class="col-md-2 col-sm-2 logo">
      <a href="/">
        <img src="img/scooby.svg" alt="Logo" width="120px" class="img-responsive"></a>
    </div>

    <div class="col-md-7 col-sm-6 search-head hidden-xs">
      <md-autocomplete
        md-no-cache="ctrl.noCache"
        md-selected-item="ctrl.selectedItem"
        md-search-text-change="ctrl.searchTextChange(ctrl.searchText)"
        md-search-text="ctrl.searchText"
        md-selected-item-change="ctrl.selectedItemChange(item)"
        md-items="item in ctrl.querySearch(ctrl.searchText)"
        md-item-text="item.name"
        md-min-length="0"
        placeholder="Search....."
        md-menu-class="autocomplete-custom-template">
        <md-item-template>
          <span class="item-title">
           
            <span> {{item.name}} </span>
          </span>
          <span class="item-metadata">
            <span class="item-metastat pull-right">
              <strong>{{item.forks}}</strong>
            </span>
          </span>
        </md-item-template>
      </md-autocomplete>
      <md-input-container class="md-block" md-no-float flex-gt-sm>
        <md-icon md-svg-src="img/locationpin.svg"></md-icon>
        <!-- <label>Location</label> -->
        <md-select ng-model="user.state" placeholder="Location">
          <md-option ng-repeat="state in states" value="{{state.abbrev}}">
            {{state.abbrev}}
          </md-option>
        </md-select>
      </md-input-container>
      <button type="button" class="search-bt">GO</button>
    </div>
    <div class="col-md-3 col-sm-4 col-xs-10 head-link">
      <p class="visible-xs mobile-menu-ic">

        <md-menu md-offset="0 -5" ng-controller="menuCtrl as ctrl">
          <md-button aria-label="Open demo menu" class="md-icon-button" ng-click="ctrl.openMenu($mdOpenMenu, $event)">
            <i class="material-icons">&#xE5D2;</i>
          </md-button>
          <md-menu-content width="4">
            <md-menu-item>
              <md-button ng-click="ctrl.announceClick($index)"> Profile </md-button>
            </md-menu-item>
            <md-menu-item>
              <md-button ng-click="ctrl.announceClick($index)"> Messages </md-button>
            </md-menu-item>
            <md-menu-item>
              <md-button ng-click="ctrl.announceClick($index)"> Sign Out </md-button>
            </md-menu-item>
          </md-menu-content>
        </md-menu>
      </p>
      <ul id="popupContainer" class="clearfix pull-right hidden-xs">
        <li><md-button class="" ng-click="newpost($event)">
          Post
        </md-button></li>

        <li class="mesg"><a href="#"><img src="img/mail.svg"> </a></li>
        <li><a href="/profile" class="profile" ng-click="showAdvanced($event)"><img src="img/macbook-wireless-mouse.jpg"> </a></li>

      </ul>
    </div>
  </div>
</header>
Bevins answered 22/12, 2016 at 6:25 Comment(5)
add class for specificity select boxFascination
facing some issues Elaborate what are the issues add a screen shot of it at least! Read your post once and see if it is understandable from a third person perspective. Also angular ? angular2? angular-material? which of these are you using?Willianwillie
It doesn't look like the angular2 tag should be used here.Acrilan
I am also facing the same issue, like when focusing the md-autocomplete it automatically scroll down the page and the drop down list's place doesn't properly rendered.Hazen
This is really a better wayMcafee
D
1

Have you inspected it in your browser? You can see the md styles overriding it probably. Add a class to it and override style, with important if needed

.md-select.fixedTop{
    top: 0px !important;
}
Dunno answered 30/3, 2018 at 19:1 Comment(0)
D
0

I think you check it .md-select.fixedTop{ top: 0px !important; }

Dorren answered 28/2, 2021 at 19:40 Comment(1)
Should be in comment section instead of answer boxTello

© 2022 - 2024 — McMap. All rights reserved.