【问题标题】:How to stretch to fill its container space?如何拉伸以填充其容器空间?
【发布时间】:2019-10-25 00:23:32
【问题描述】:

在导航栏中有 3 个具有包装 div 元素的链接,问题是 div 内部的链接没有被拉伸。检查屏幕截图 - 我需要点击链接在页面之间导航:

我希望导航中的链接可以拉伸空间,例如 with 和 heigh 100%;

这是导航栏的css

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100px;
  color: var(--color-white);
  background-color: var(--color-black);

  .user-nav {
    display: flex;
    align-items: center;

    &-item {
      width: 118px;
      font-size: 20px;
      font-weight: 500;
      line-height: 30px;
      text-align: center;
      color: var(--color-grey);
    }

    &-item-active {
      width: 118px;
      font-size: 20px;
      font-weight: 500;
      line-height: 30px;
      text-align: center;
      color: var(--color-grey);
      box-shadow: inset 0 -4px 0 var(--color-red); // made border bottom inside of element
    }

    &-item-link {
      text-decoration: none;
      color: inherit;
    }
  }

  .logo {
    width: 30px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);

    img {
      width: 100%;
    }
  }
}

导航栏的HTML:

<header className="header">
        <nav className="user-nav">
          <div className={this.handleActiveRoute('/', activeRoute)}>
            <Link href="/">
              <a className="user-nav-item-link">Dashboard</a>
            </Link>
          </div>
          <div className={this.handleActiveRoute('/search', activeRoute)}>
            <Link href="/search">
              <a className="user-nav-item-link">Search</a>
            </Link>
          </div>
          <div className={this.handleActiveRoute('/collections', activeRoute)}>
            <Link href="/collections">
              <a className="user-nav-item-link">Collections</a>
            </Link>
          </div>
        </nav>
        <div className="logo">
          <img src={Logo} alt="logo" />
        </div>
        <div className="user-nav-icon">
          <div className="user-nav-icon-notification">
            <span className="icon-bell-o" />
          </div>
          <div className="user-nav-icon-settings">
            <span className="icon-cog" />
          </div>
        </div>
      </header>

如何使 div 内的链接具有 100% 的宽度和高度?

【问题讨论】:

    标签: html css sass


    【解决方案1】:

    链接上的“显示:阻止”可能有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-07
      相关资源
      最近更新 更多