javascript - 将整页背景添加到 Angular JS 中的单个 View

标签 javascript jquery css angularjs

我需要在我的应用中为单个 View 添加全屏 CSS 背景。我试图通过向 body 添加一个类来实现这一点然而,这仍保留在缓存中,并在切换 View 时保留在正文中。

我遇到这个问题是因为我的 <div ng-view=""></div><body> 内所以我不能轻易地从 View 中添加全屏 BG。

最佳答案

为了快速简单地回答,这就是我所做的。

将条件类应用到 ng-view

index.html

ng-class="{'homebg' : home}"

样式.scss

.homebg { 高度:100%; 背景图像:url('../images/home-bg.jpg'); 背景尺寸:封面; 背景位置:中心中心; }

Controller.js

$scope.home = true;

关于javascript - 将整页背景添加到 Angular JS 中的单个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33202625/

相关文章:

javascript - 获取选择中选项的值 - HTML

javascript - v-将图像从对象绑定(bind)到 img src 不起作用

javascript - .click() 事件时 'Open in new tab/window'

javascript - 花式盒子 3 : Disable zoom when image is clicked

javascript - Angularjs - $http 成功与那时

javascript - "TypeError: req.flash is not a function"使用带有 nodejs 的 Passport ,用户名和密码 auth

jQuery 通过掩码选择

html - 如何制作响应式填充?

iphone - 'background-attachment: fixed' 的解决方法在 iOS4 中不起作用

css - 悬停弹出大小限制在表格数据内。如何完整显示?