簡體   English   中英

我該怎么做才能將此菜單按鈕從側邊欄移到右側?

[英]What can I do to move this menu button from my sidebar to the right?

你能幫我嗎?。

目前我正在創建這個 Angular Sidenav組件,沒有 jquery 或 Angular Material,只有 Angular 工具、css 和 html。

我正在使用 ng-If 在單擊紅色按鈕時銷毀組件,我在按鈕中使用 ng-class 來更改圖標,並且我正在使用 ng-class 嘗試移動包裝器 Div按鈕,但它不起作用。 div 和按鈕不動。

HTML

<div class="sidebar" *ngIf="!open">
  <header>My App</header>
<ul>
  <li><a href="#"><i  class="fa fa-tachometer"></i>Dashboard</a></li>
  <li><a href="#"><i class="fa fa-external-link" aria-hidden="true"></i>Shortcuts</a></li>
  <li><a href="#"><i  class="fa fa-eye" aria-hidden="true"></i>Overview</a></li>
  <li><a href="#"><i class="fa fa-calendar" aria-hidden="true"></i>Events</a></li>
  <li><a href="#"><i class="fa fa-building-o" aria-hidden="true"></i>About</a></li>
  <li><a href="#"><i class="fa fa-paper-plane" aria-hidden="true"></i>Contact</a></li>
</ul>
</div>
<!-- SideNav -->
<!-- close / open button -->
<div id="menu" (click)="prueba()" [ngClass]="{'closed': !open}">
  <a  id="open-close">
    <i class="fa" [ngClass]="{'fa-bars': !open, 'fa-times': open}" ></i>
  </a>
</div>
<!-- close / open button -->

打字稿

    export class SidenavaComponent implements OnInit {

  open: boolean;

  constructor() {

  }

  prueba() {
    this.open = !this.open;
    console.log(this.open);
  }

  ngOnInit() {
    this.open = true;
  }

}

css

@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,400i,500');
@import url('https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');

.sidebar {
  position: fixed;
  width: 20%;
  height: 100%;
  background: white;
  box-shadow: 2px 2px 5px #999;
}
.sidebar header {
  font-size: 22px;
  color: white;
  line-height: 70px;
  text-align: center;
  background: #063146;
  user-select: none;
}
.sidebar ul a{
  display: block;
  height: 100%;
  width: 100%;
  line-height: 65px;
  font-size: 20px;
  color:#063146;
  padding-left: 40px;
  box-sizing: border-box;
  transition: .4s;
}
ul li:hover a{
  padding-left: 50px;
}
.sidebar ul a i{
  margin-right: 16px;
}


/* boton de cierre */

#menu {
position: fixed;
background-color: tomato;
width: 40px;
height:40px;
margin-left: 21%;
border-radius: 200px 200px 200px 200px;
-moz-border-radius: 200px 200px 200px 200px;
-webkit-border-radius: 200px 200px 200px 200px;
border: 0px solid #000000;
}

#open-close{
margin-top: 12%;
width: 35px;
height:35px;
margin-left: 21%;
}

.closed{
  margin-left: 1px;
}

在此處輸入圖片說明 在此處輸入圖片說明

我想你想要這樣的東西:

Stackblitz: https ://stackblitz.com/edit/angular-ki5mus

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM