set button to appear on hover

人盡茶涼 提交于 2019-12-25 01:45:56

问题


I have a button in angular 4 material table cell that I'd like to appear only when hover on table row:

<md-cell *cdkCellDef="let row" contenteditable='false' > 
        <div *ngIf="!row.editorEnabled" >{{row.goalStatusName}}
            <button md-icon-button><md-icon (click)="row.editorEnabled=true;" mdTooltip="Edit">mode_edit</md-icon></button>
          </div>
</md-cell>

How do I achieve this?

Update: Entire code:

<md-cell *cdkCellDef="let row" contenteditable='false' > 
        <div *ngIf="!row.editorEnabled" >{{row.goalStatusName}}
            <button md-icon-button><md-icon (click)="row.editorEnabled=true;" class="editButton" mdTooltip="Edit">mode_edit</md-icon></button>
          </div>
        <div *ngIf="row.editorEnabled" >
          <md-input-container><input mdInput [(ngModel)]="row.goalStatusName" #goalName></md-input-container>
            <button md-icon-button>
              <md-icon (click)="modifyGoal(row.goalStatusId,row.goalStatusName)" mdTooltip="Save" style="color:green;font:bold;" >done</md-icon>
            </button>
            <button md-icon-button>
              <md-icon (click)="row.editorEnabled=false" mdTooltip="Cancel" style="color:red;font:bold;" >clear</md-icon>
            </button>
          </div>
    </md-cell>

回答1:


button{ display:none}
md-cell:hover{

  button{
     display:block
  }
}



回答2:


.editButton{ visibility: hidden}
md-cell:hover .editButton{
visibility: visible;
}

This worked!



来源:https://stackoverflow.com/questions/46022971/set-button-to-appear-on-hover

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!