- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正要用拳头砸穿我的电脑屏幕。我有一个对话框,它拒绝在屏幕底部的提交按钮上方移动一英寸——我希望它位于最顶部。
我试过:
this.dialogBox.open(thankYouModal, {position: {top: '0%', left: '20%'}});
我试过为顶部设置负数和正数。我得到的最好的结果是我可以将模式进一步向下移动,这样用户必须向下滚动才能关闭它。然而,那个笨蛋不会让提交按钮上的毛发动过
我试图将样式表放入组件中,如下所示:
div#cdk-overlay-0.cdk-overlay-container{
position: fixed !important;
left: 20%;
top: 0%;
background-color: white;
pointer-events: auto;
}
我无法让这个东西在提交按钮上方移动一英寸。如果有人帮助我弄清楚我做错了什么,我会给他们我的第一个 child 。
(是的,我知道我很戏剧化,但我已经与之抗争并在网上搜索了 3 个小时;我是一个失败的人……)
编辑
这是 thankYouModalComponent 代码:
import {Component} from "@angular/core";
import {MdDialogRef, MdDialogConfig} from "@angular/material";
@Component({
selector: 'thank-you-modal',
template: `
<h3>Thank You for Your Submission</h3>
<p>Your Feedback has been Saved.</p>
<button md-raised-button (click)="dialogRef.close()">Close</button>
`,
styles: [`
.md-dialog-container {
position: fixed !important;
left: 20%;
top: 0%;
background-color: white;
z-index: 100000;
}`]
})
export class ThankYouComponent{
constructor(public dialogRef: MdDialogRef<any>, ) {}
}
组件的调用方法和构造函数如下:
constructor(@Inject(FormBuilder) fb : FormBuilder,
private feedbackService: feedbackService,
private dialog : MdDialog){
-------<irrelevant code here>------------
}
submitFeedback(group : FormGroup){
const feedback = new Feedback( group.get('nameBox').value,
group.get('productBox').value,
group.get('upsBox').value,
group.get('downsBox').value);
if(confirm("Is the data entered what you want to submit?")){
this.dialog.open(ThankYouComponent, {position: {top: '0%', left:'20%'}});
}
表单底部的结果对话框
最佳答案
更好的方法是注入(inject)按钮元素并将其传递到对话框中。这样,对话框就有了关于如何调整大小/定位的完整上下文(并利用 element.getBoundingClientRect()
函数):
对话框组件:
import { Component, ElementRef, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogConfig, MatDialogRef } from '@angular/material';
@Component({
selector: 'app-dialog-component',
templateUrl: './dialog.component.html',
styleUrls: ['./dialog.component.scss']
})
export class MyDialogComponent implements OnInit {
private readonly _matDialogRef: MatDialogRef<MyDialogComponent>;
private readonly triggerElementRef: ElementRef;
constructor(_matDialogRef: MatDialogRef<MyDialogComponent>,
@Inject(MAT_DIALOG_DATA) data: { trigger: ElementRef }) {
this._matDialogRef = _matDialogRef;
this.triggerElementRef = data.trigger;
}
ngOnInit() {
const matDialogConfig: MatDialogConfig = new MatDialogConfig();
const rect = this.triggerElementRef.nativeElement.getBoundingClientRect();
matDialogConfig.position = { left: `${rect.left}px`, top: `${rect.bottom - 50}px` };
matDialogConfig.width = '300px';
matDialogConfig.height = '400px';
this._matDialogRef.updateSize(matDialogConfig.width, matDialogConfig.height);
this._matDialogRef.updatePosition(matDialogConfig.position);
}
cancel(): void {
this._matDialogRef.close(null);
}
}
用法:
onShowDialog(evt: MouseEvent): void {
const target = new ElementRef(evt.currentTarget);
const dialogRef = this._matDialog.open(MyDialogComponent, {
data: { trigger: target }
});
dialogRef.afterClosed().subscribe( _res => {
console.log(_res);
});
}
关于angular - 如何在触发按钮上方放置一个对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43476958/
假设有一个具有非常简单的 UI 层次结构的窗口,它只有两个同级: NSTextView 和 NSButton,并且它们确实重叠。 我的问题是,为什么光标悬停在按钮上时会有所不同,具体取决于其下方是否有
例如,当我将 TPanel 添加到表单并使用 alTop 对齐它,然后将 TMainMenu 添加到同一表单时,主菜单位置会覆盖面板位置,以便主菜单保持在窗体的最顶层,面板显示在其下方。 是否可以覆盖
我想构建一个 UI,其中我在屏幕顶部有一些固定的小部件(在所有选项卡上可见),然后在它们下面我想要一个 TabBarView(底部有选项卡栏),这是否可能而不使您的自己的标签小部件还是 TabBarV
我一直在这里关注 Phaser 3 的介绍 http://phaser.io/tutorials/making-your-first-phaser-3-game并发现我的 Angular 色“悬停”在
我在 View 中间有一个 UITextView,在 View 底部有一个 UIToolBar。当我触摸 UITextView 时,我希望在 UIToolBar 上方出现一个可视键盘。我该怎么做? 最
我正在尝试制作井字游戏,我有一个 3 x 3 按钮网格,但我想在按钮上方有一个栏,显示分数和玩家姓名,有人可以帮助我吗?到java,不知道从哪里开始。 import javax.swing.*; im
是否可以指定 noUiSlider 绘制的工具提示的位置?似乎默认情况下它将第一个放在 slider 上,第二个放在下面。我理解这里的可用性目标,但我想把两者都放在上面或下面。 示例(带有上方和下方的
我的应用程序中有主详细布局(参见左图): 我为操作栏设置了导航模式列表(使用它来过滤第二个 fragment 中的 ListView ): final ActionBar actionBar = ge
我是 iOS 编程新手,在使用 XLPagerTabStrip(github.com/xmartlabs/XLPagerTabStrip) 时遇到了困难。我按照它的教程,成功在VC的顶部添加了Page
这个问题适用于任何项目,但在这种情况下,我想将我的图像放置在 map 上方,目前它位于 map 下方。 我是 swift 1.2 的新手,所以我不知道如何组合一个示例,任何帮助将不胜感激。 最佳答案
我如何在 javascript 中确定一个元素是否在视口(viewport)上方(用户已经滚动过它)(不仅仅是它是否可见)? 在这段代码中: 控制台日志(iselement1aboveviewport
我正在尝试将工具栏添加到我的 View Controller 。 我的 View Controller : -(void)loadView { UIWebView *webView = [[U
我知道这是一个一般性问题,但任何方向都会有所帮助。 所以我正在使用这个模块 https://github.com/maxep/MXSegmentedPager尝试重新创建 Twitter 的个人资料页
我需要在保存按钮下放置一个带有 id 的 div。这是 html 代码: save 这是我的 : 通过这种方式,div 隐藏了按钮,我的目的是在 div 上方显示按钮。
我试图将我的整个 refreshControl 放在 tableview 后面。我可以通过这样做来放置实际的微调器: self.tableView.addSubview(refreshContro
这在 Safari 和 Firefox 中都会发生。我的导航栏看起来像这样: Test 相关的 CSS 看起来像: li { float: left } a:hover {
我在 CSS 中的 #footermain div 上有一个框阴影,但我无法让它显示在绿色页脚上方。我什么都试过了,还是想不通。 #footermain { background: #1f6c
我试图将图像部分放置在旋转 slider 上方( slider 上侧的一部分应该被图像覆盖)我试过 image{position:relative; z-index:10; } slider{posi
我认为这是一个简单的问题,但我无法理解它。我在页面顶部有一个固定的 div,当我向下滚动查看内容时,内容(文本)显示在该固定 div 上方 5 像素的边距中。该边距(黑色,请参阅 https://js
我有两个 div,在页脚配置中。目的是在悬停时通过显示隐藏的 div 向上扩展页脚。 #extendedFooter, #test { display: none; } #standardFo
我是一名优秀的程序员,十分优秀!