代码之家  ›  专栏  ›  技术社区  ›  Caverman

Flexbox项目不去集装箱底部?

  •  0
  • Caverman  · 技术社区  · 8 年前

    从这个问题中你会发现,我对Flexbox和SASS还是新手。我有一个MVC应用程序,我试图根据头部登录信息是否经过身份验证来调整它们。

    我试着用flexbox来完成这些。我的想法是我将有一个整体的父容器 "header_account-info" ,中的徽标 "header__logo" 子容器,以及 "header_account-user" "header-account-login" . 为了测试,我使用了“header account login”容器。

    用下面的代码我不能得到 “头帐户登录” 容器要有一个背景色(用于测试)也不能使其与底部对齐。

    https://codepen.io/anon/pen/WgGxQL

    为什么我在我的 “头帐户登录”

    HTML格式

    <div class="header">
            <div class="header__logo">
                <img src="~/images/logo.png" class="header-logo" />
            </div>
            <div class="header_account-info">
    
    
                    <div class="header-account-login">
                        <a href="@Url.Action("Register", "Account")" id="registerLink" class="btn btn-outline-secondary">
                            <i class="far fa-user-plus"></i> Register
                        </a>
                        <a href="@Url.Action("Login", "Account")" id="loginLink" class="btn btn-outline-secondary">
                            <i class="fas fa-sign-in-alt"></i> Log In
                        </a>
                    </div>
            </div>
        </div>
    

    萨斯

    .header {
        display: flex;
        padding: 3px;
    
        &__logo {
            /*flex: 1;*/
            margin-right: auto;
            background-color: aqua;
            height: 100px;  /*TESTING*/
        }
    
        &__account-info {
            display: flex;
            background-color: aquamarine;
        }
    
        &__account-user {
            background-color: blanchedalmond;
        }
    
        &__acount-login {
            align-items: flex-end;
            background-color: aquamarine;
        }
    }
    
    2 回复  |  直到 8 年前
        1
  •  1
  •   Paulie_D    8 年前

    为什么在我的“header account login”容器中看不到背景色,而我认为我有正确的设置,使按钮转到容器的末尾(底部)?

    至于劳特号,我想这就足够了:

    .header {
      display: flex;
      padding: 3px;
      justify-content: space-between;
    }
    
    .header__logo {
      /*flex: 1;*/
      margin-right: auto;
      background-color: aqua;
      height: 100px;
    }
    
    .header__account-info {
      display: flex;
      align-items: flex-end;
    }
    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.2/css/bootstrap.min.css" rel="stylesheet" />
    <div class="header">
      <div class="header__logo">
        <img src="http://www.fillmurray.com/g/140/100" class="header-logo" />
      </div>
      <div class="header__account-info">
    
    
        <div class="header__account-login">
          <a href="@Url.Action(" Register ", "Account ")" id="registerLink" class="btn btn-outline-secondary">
            <i class="far fa-user-plus"></i> Register
          </a>
          <a href="@Url.Action(" Login ", "Account ")" id="loginLink" class="btn btn-outline-secondary">
            <i class="fas fa-sign-in-alt"></i> Log In
          </a>
        </div>
      </div>
    </div>
        2
  •  -2
  •   iAMkVIN_S    8 年前

    .header-account-info {
        position: relative;
    }
    .header-account-login {
        background-color: red;
        position: absolute;
        bottom: 0px;
        right: 0px;
        width: 158px;
    }
    

    您试图调用类的方式(即“&uyu acount-login”)是错误的-只需像我的示例一样为自己提供完整的类名。