css - angularjs中的警报对话框导致页面滚动到顶部
问题描述
我想在我的 angularjs 应用程序中使用一个警报对话框,而不是现在所有的$window.alert
。在我的应用程序的每个控制器中,我都插入了这个(https://material.angularjs.org/latest/demo/dialog):
$scope.showAlert = function(ev) {
$mdDialog.show(
$mdDialog.alert()
.parent(angular.element(document.body))
.clickOutsideToClose(true)
.title('This is an alert title')
.textContent('You can specify some description text in here.')
.ariaLabel('Alert Dialog Demo')
.ok('Got it!')
.targetEvent(ev)
);};
在我的 style.css 文件中我添加了这个:
.md-dialog-is-showing {
top: 0 !important;
}
问题是,当调用 $scope.showAlert 时,模式对话框下的页面会滚动到顶部,而当我关闭对话框时,它会返回到先前的位置。如何防止滚动到顶部以在调用它的相同位置显示对话框?
---------- 已编辑 ----------
我试图删除添加的 css 规则,但没有出现整个网页,包括对话框。我注意到在正文标签中,自动生成的样式如下(顶部:-1505px 导致问题)
<body ng-app="configuratorApp" class="ng-scope md-dialog-is-showing" style="position: fixed; width: 100%; top: -1505px; overflow: hidden;">
<md-backdrop class="md-dialog-backdrop md-opaque ng-scope" style="height: 2059px; position: fixed;" aria-hidden="true"></md-backdrop> ...
解决方案
推荐阅读
- r - equivalent of hoverEdge for clicks in in Shiny for visNetwork
- python - Filtering what gets displayed on graph (Sypder (Python 3.7)
- python-3.x - Problems about realization of VAE with Pytorch
- python - Use tensorflow TPU strategy; get UnavailableError
- shopify - 循环遍历在 Liquid 中附加 _indexNumber 的元字段,这些元字段需要分配给对象值以匹配特定键
- microsoft-teams - 使用该 webapp 为独立 webapp 和 Teams 选项卡设置通用身份验证工作流
- excel - 使用 VBA 更新共享点列表
- mysql - 我需要一个查询来做一些特定的事情
- jquery - 我正在尝试使用 grep 但无法使其正常工作
- node.js - 在 Angular 项目中安装 agora 时出错