英文:
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
[![...
<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>
...][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 <a>
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;
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论