html - 使按钮成为蓝条的大小?
问题描述
.nav-info {
height: auto;
background-color: darkblue;
color: white;
padding: 1em;
padding-left: 5%;
flex-direction: row;
justify-content: space-between;
}
.flexbox {
display: flex;
}
.info a {
color: white;
text-decoration: none;
font-weight: 500;
letter-spacing: 0.8px;
}
.appointment {
height: 100%;
}
.btn {
color: white;
background-color: skyblue;
font-weight: bold;
border: none;
}
<header>
<div class="nav-info flexbox">
<div class="info flexbox">
<a href="tel:+1 (786) 859-7101">
<i class="fas fa-phone-alt"></i> +1 (786) 859-7101
</a>
|
<a href="email:info@gemfs.company">
<i class="fas fa-envelope"></i> info@gemfs.company
</a>
</div>
<div class="appointment">
<button class="btn">
Make an appointment
</button>
</div>
</div>
</header>
我需要按钮来覆盖整个高度。我正在使用 flexbox,我不知道这是否会影响 div 的大小。我尝试了很多东西,但我不知道如何解决它。我想做的不是导航栏。另一方面,电话和邮件的信息非常接近,有没有办法使用flexbox来补救呢?
我希望它看起来像这样,但底部是天蓝色。我需要按钮来占据所有高度。
解决方案
您可以使用“flex”属性展开弹性项目:(https://css-tricks.com/almanac/properties/f/flex/)
如果您希望按钮具有容器的高度,一种方法是在容器上设置固定高度,然后您可以在按钮上使用 height: 100% (确保考虑到填充)。
推荐阅读
- postgresql - 不同版本的 postgresql 中的反斜杠行为
- memory - 如何增加 Oracle 19c DB 使用的内存
- sirikit - SiriKit:在 IntentsDefinition 文件中定义的快捷方式未显示在 macOS 的快捷方式应用程序中?
- tkinter - Tkinter 图像定位
- javascript - 在 React 组件中复制嵌套映射
- angular - 版本 12 的 Angular 应用程序中的编译错误尝试使用 Angular 10 中内置的 Angular 库
- assembly - 在程序集中打印文本
- reactjs - 当函数是抽象的时,在函数内部引用类函数。(无法读取未定义的属性)
- ios - Swift FCM 向特定令牌发送通知在后台不工作
- c++ - 在 C++ 中使用 Liebniz 公式逼近 Pi