position: fixed; does not work in an AngularJS template

1

This is my code, the component I have it in a template it is not in the index.html, everything shows it correctly but for some reason the position : fixed; of my CSS does not work, does anyone have any idea why?

exampleApp.component('backbuttonComponent', {
    template: '<a id="back-button" ng-href="/"></a>'
  });
#back-button {
  position: fixed !important;
  width: 60px;
  height: 60px;
  bottom: 10px;
  left: 10px;
  border-radius: 50%;
  background: url("../svg/back-button.svg") no-repeat center center;
  background-size: 24px 24px;
  background-color: #3c3f41;
  z-index: 12 !important;
  box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12), 0 3px 5px -1px rgba(0, 0, 0, 0.2); /* 6dp */
}
<backbutton-component></backbutton-component>
    
asked by adrianojosue 18.07.2016 в 00:41
source

1 answer

-2

Place it in position: absolute and every time you scroll on the screen, I got how much you moved with the scroll ( var scroll = $ (window ) .scrollTop (); ) and increase / decrease the bottom attribute by adding / subtracting that value every time you scroll on the screen:

$("#back-button").css("top", $(window).height() - 10); //Es igual que poner bottom:10px;

var topInicial = $("#back-button").offsetTop();

$(window).scroll(function(){
    scroll = $(window).scrollTop();//Scroll hecho desde 0 hasta la posición actual
    $("#back-button").css("top", topInicial + scroll);
});

This is not with angularJs, but it works perfectly.

    
answered by 18.07.2016 в 01:37