增加导航栏品牌的大小

huangapple go评论68阅读模式
英文:

increase size of navbar-brand

问题

我正在构建一个落地页,但我的标志看起来很小,我正在使用Bootstrap 5。

style.css

...
.navbar-brand {
  width: 3.5rem;
  padding: 0 0;
  margin: 0.3rem 0;
  position: relative;
}

.navbar-brand img {
  width: 100%;
  height: auto;
}

body .navbar-brand .logo-dark {
  display: none;
}

body.dark-layout .navbar-brand .logo-light {
  display: none;
}

body.dark-layout .navbar-brand .logo-dark {
  display: block;
}

@media (min-width: 576px) {
  .navbar-expand-sm .navbar-brand {
    width: 4.5rem;
  }

  .navbar-expand-sm.headroom--not-top:not(.headroom--pinned):not(.headroom--bottom) {
    transform: translateY(-100%);
  }

  .navbar-expand-sm .nav-item {
    height: 4.5rem;
    display: flex;
    align-items: center;
  }

  .navbar-expand-sm .nav-item:not(:first-child) {
    margin-left: 1.25rem;
  }
}

@media (min-width: 768px) {
  .navbar-expand-md .navbar-brand {
    width: 4.5rem;
  }

  .navbar-expand-md.headroom--not-top:not(.headroom--pinned):not(.headroom--bottom) {
    transform: translateY(-100%);
  }

  .navbar-expand-md .nav-item {
    height: 4.5rem;
    display: flex;
    align-items: center;
  }

  .navbar-expand-md .nav-item:not(:first-child) {
    margin-left: 1.25rem;
  }
}

@media (min-width: 992px) {
  .navbar-expand-lg .navbar-brand {
    width: 4.5rem;
  }

  .navbar-expand-lg.headroom--not-top:not(.headroom--pinned):not(.headroom--bottom) {
    transform: translateY(-100%);
  }

  .navbar-expand-lg .nav-item {
    height: 4.5rem;
    display: flex;
    align-items: center;
  }

  .navbar-expand-lg .nav-item:not(:first-child) {
    margin-left: 1.25rem;
  }
}

@media (min-width: 1200px) {
  .navbar-expand-xl .navbar-brand {
    width: 4.5rem;
  }

  .navbar-expand-xl.headroom--not-top:not(.headroom--pinned):not(.headroom--bottom) {
    transform: translateY(-100%);
  }

  .navbar-expand-xl .nav-item {
    height: 4.5rem;
    display: flex;
    align-items: center;
  }

  .navbar-expand-xl .nav-item:not(:first-child) {
    margin-left: 1.25rem;
  }
}

@media (min-width: 1400px) {
  .navbar-expand-xxl .navbar-brand {
    width: 4.5rem;
  }

  .navbar-expand-xxl.headroom--not-top:not(.headroom--pinned):not(.headroom--bottom) {
    transform: translateY(-100%);
  }

  .navbar-expand-xxl .nav-item {
    height: 4.5rem;
    display: flex;
    align-items: center;
  }

  .navbar-expand-xxl .nav-item:not(:first-child) {
    margin-left: 1.25rem;
  }
}

.navbar-expand .navbar-brand {
  width: 4.5rem;
}
...

这是我的HTML文件

<body>
  <nav class="navbar navbar-expand-lg navbar-transparent navbar-sticky navbar-light">
    <div class="container-fluid px-xl-0 mx-xl-5">
      <a class="navbar-brand" href="index.html">
        <img src="{{ url_for('static', filename='images/logo-no-background.svg') }}" alt="" class="">
      </a>
      ...
    </div>
  </nav>
  ...
</body>

希望这些信息对你有所帮助。

英文:

I'm building a landing page but my logo is looking very small and i~m using bootstrap 5

style.css

...
.navbar-brand {
width: 3.5rem;
padding: 0 0;
margin: 0.3rem 0;
position: relative;
}
.navbar-brand img {
width: 100%;
height: auto;
}
body .navbar-brand .logo-dark {
display: none;
}
body.dark-layout .navbar-brand .logo-light {
display: none;
}
body.dark-layout .navbar-brand .logo-dark {
display: block;
}
@media (min-width: 576px) {
.navbar-expand-sm .navbar-brand {
width: 4.5rem;
}
.navbar-expand-sm.headroom--not-top:not(.headroom--pinned):not(.headroom--bottom) {
transform: translateY(-100%);
}
.navbar-expand-sm .nav-item {
height: 4.5rem;
display: flex;
align-items: center;
}
.navbar-expand-sm .nav-item:not(:first-child) {
margin-left: 1.25rem;
}
}
@media (min-width: 768px) {
.navbar-expand-md .navbar-brand {
width: 4.5rem;
}
.navbar-expand-md.headroom--not-top:not(.headroom--pinned):not(.headroom--bottom) {
transform: translateY(-100%);
}
.navbar-expand-md .nav-item {
height: 4.5rem;
display: flex;
align-items: center;
}
.navbar-expand-md .nav-item:not(:first-child) {
margin-left: 1.25rem;
}
}
@media (min-width: 992px) {
.navbar-expand-lg .navbar-brand {
width: 4.5rem;
}
.navbar-expand-lg.headroom--not-top:not(.headroom--pinned):not(.headroom--bottom) {
transform: translateY(-100%);
}
.navbar-expand-lg .nav-item {
height: 4.5rem;
display: flex;
align-items: center;
}
.navbar-expand-lg .nav-item:not(:first-child) {
margin-left: 1.25rem;
}
}
@media (min-width: 1200px) {
.navbar-expand-xl .navbar-brand {
width: 4.5rem;
}
.navbar-expand-xl.headroom--not-top:not(.headroom--pinned):not(.headroom--bottom) {
transform: translateY(-100%);
}
.navbar-expand-xl .nav-item {
height: 4.5rem;
display: flex;
align-items: center;
}
.navbar-expand-xl .nav-item:not(:first-child) {
margin-left: 1.25rem;
}
}
@media (min-width: 1400px) {
.navbar-expand-xxl .navbar-brand {
width: 4.5rem;
}
.navbar-expand-xxl.headroom--not-top:not(.headroom--pinned):not(.headroom--bottom) {
transform: translateY(-100%);
}
.navbar-expand-xxl .nav-item {
height: 4.5rem;
display: flex;
align-items: center;
}
.navbar-expand-xxl .nav-item:not(:first-child) {
margin-left: 1.25rem;
}
}
.navbar-expand .navbar-brand {
width: 4.5rem;
}
...

This is my html file

[![...
&lt;body&gt;
&lt;nav class=&quot;navbar navbar-expand-lg navbar-transparent navbar-sticky navbar-light&quot;&gt;
&lt;div class=&quot;container-fluid px-xl-0 mx-xl-5&quot;&gt;
&lt;a class=&quot;navbar-brand&quot; href=&quot;index.html&quot;&gt;
&lt;img src=&quot;{{ url_for(&#39;static&#39;, filename=&#39;images/logo-no-background.svg&#39;) }}&quot; alt=&quot;&quot; class=&quot;&quot;&gt;
&lt;/a&gt;
...][1]][1]

答案1

得分: 1

你的 navbar-brand 大小没有改变,因为它的显示属性是 inline,因为 <a> 标签默认的显示属性是 display:inline

display:block 添加到 navbar-brand 中,你的 width 将生效:

.navbar-brand {
    width: 3.5rem;
    padding: 0 0;
    margin: 0.3rem 0;
    position: relative;
    display: block;
}
英文:

your navbar-brand size isn't changing because its display is inline as &lt;a&gt; tag has display:inline by default.

add display:block to the navbar-brand and your width will take effect:

.navbar-brand {
width: 3.5rem;
padding: 0 0;
margin: 0.3rem 0;
position: relative;
display: block;
}

huangapple
  • 本文由 发表于 2023年5月28日 01:49:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/76348271.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定