html - Bootstrap CTA按钮右栏全高
问题描述
我在尝试让我的右列拥有一个占据列的整个高度和宽度的按钮时遇到了麻烦。下面是我的代码。我试过调整高度,设置位置,但仍然没有在这个奇怪的结构中找到任何运气。
我使用 Twitter Bootstrap 4、SCSS 和 jQuery 作为我的构建框架。
我的引导代码
.cta-section {
background: #243635;
.center-align {
align-items: $center-align;
}
.section-content-left {
text-align: left;
padding: 2.625rem 3.5rem 2.625rem 8.125rem;
}
h2 {
font-size: $h2size;
font-family: $nunito;
font-weight: 200;
color: $colorwhite;
}
p {
font-size: $font15px;
color: $colorwhite;
line-height: 1.625rem;
opacity: .77;
}
.cta-block-right {
background: $colorgreen;
font-family: $nunito;
color: $colorwhite;
.cta-large {
color: $colorwhite;
b {
color: $colorwhite !important;
}
}
}
} // End Cta Section
<div class="cta-section">
<div class="container-fluid">
<div class="row center-align">
<div class="col-md-8 col-sm-12">
<div class="section-content-left">
<h2> We Make It Easy To Find Work You Love</h2>
<p> It can seem daunting applying for a new career. Not to mention that you're interested in doing it in an innovative way (remotely). Don't worry, we have a simple process and we'll walk you through from start to finish. </p>
</div>
<!-- end section-content-left -->
</div>
<!-- col-md-8 col-sm-12 -->
<div class="col-md-4 col-sm-12 column-bg-green" style="
height: 100%;
width: 100%;
position: relative;
">
<div class="cta-block-right" style="
/* position: absolute; */
">
<a class="cta-large" href="#"> <b> See Our Process </b> </a>
</div>
<!-- end cta-block-right -->
</div>
<!-- end col-md-4 col-sm-12 -->
</div>
<!-- end row -->
</div>
<!--end container -->
</div>
解决方案
解释
在 Bootstrap 中,4 rows和col是使用 Flexbox 制作的。因此,默认情况下,Bootstrap col采用可用的整个高度,因为它的行flex 容器的父级的默认align-item
属性是“stretch”。
解决方案
只需删除所有内联样式并.h-100
在.cta-block-right
按钮上添加 Bootstrap CSS 类。
<div class="col-md-4 col-sm-12 column-bg-green">
<div class="cta-block-right h-100">
<a class="cta-large" href="#"> <b> See Our Process </b> </a>
</div>
<!-- end cta-block-right -->
</div>
<!-- end col-md-4 col-sm-12 -->
应该这样做:)
推荐阅读
- oracle - Oracle 12c 标识列在 ETL 加载期间插入表时跳过了大块数字
- android - Firebase 动态链接生命周期
- database - 多个数据库连接 - Zendframework
- javascript - 超过 32 个字节值
- asp.net-mvc - ASP.NET MVC 编辑单个列的所有行
- python - 使用 autograd.grad() 作为损失函数的参数(pytorch)
- angular - 主机 url 更改后站点在本地网络中可用
- javascript - React Native 滑块 onValueChange 调用 setState 使滑块滞后
- api - Soundcloud Widget API 仅在 Chrome 中给出错误:AudioContext 不允许启动
- jquery - 单击外部输入时的格式数字