gpt4 book ai didi

html - 使用 Bootstrap 平衡图像的文本叠加

转载 作者:太空狗 更新时间:2023-10-29 16:39:10 26 4
gpt4 key购买 nike

我有一行包含三个图像和覆盖它们的文本。我似乎无法在单独的部分中平衡文本的左右两侧。它应该看起来像这样:

enter image description here

我能够正确设置左侧的文本,但无法平衡右侧的文本并在各部分之间设置垂直管道,并带有右边框或左边框。

     .practice-areas {
h1 {
font-weight: 600;
font-size: 60px;
font-family: 'Open Sans Condensed';
text-transform: uppercase;
color: #ffffff;
position: absolute;
bottom: 10%;
left: 50%;
-moz-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
-webkit-font-smoothing: antialiased;
}
h5 {
text-transform: uppercase;
color: #ffffff;
position: absolute;
bottom: 10%;
left: 65%;
-moz-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
-webkit-font-smoothing: antialiased;
}
p {
font-family: 'Open Sans Condensed';
font-size: 20px;
text-transform: uppercase;
color: #ffffff;
position: absolute;
bottom: 10%;
left: 55.4%;
-moz-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
-webkit-font-smoothing: antialiased;
}
.result {
color: $grey;
bottom: 7%;
font-size: 16px;
right: 38%;
}
.square-1 {
background-image: url('https://placeholdit.imgix.net/~text?txtsize=33&w=350&h=150');
background-size: cover;
height: 413px;
@include breakpoint(xsmin) {
height: 213px;
}
}
.square-2 {
background-image: url('https://placeholdit.imgix.net/~text?txtsize=33&w=350&h=150');
background-size: cover;
height: 413px;
@include breakpoint(xsmin) {
height: 213px;
}
}
.square-3 {
background-image: url('https://placeholdit.imgix.net/~text?txtsize=33&w=350&h=150');
background-size: cover;
height: 413px;
@include breakpoint(xsmin) {
height: 213px;
}
}
}
     <div class="row practice-areas">
<div class="row practice-areas">
<div class="col-lg-12">
<div class="col-lg-4 square-1">
<div class="left">
<h1 class="amount">$90.2</h1>
<p class="million">million</p>
<p class="result">text</p>
</div>
<div class="right">
<h5 class="case">COMPANY NAME</h5>
</div>
</div>
<div class="col-lg-4 square-2">
<h1>$90.2</h1>
<p>million</p>
<p class="result">company</p>
</div>
<div class="col-lg-4 square-3">
<h1>$90.2</h1>
<p>million</p>
<p class="result">COMPANY</p>
</div>
</div>
</div>
</div>

最佳答案

如果你使用bootstrap V3那么它会是这样的。我不知道您使用的是 Bootstrap 3 还是 4。您的 HTML 结构也不正确。

@import url("https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700");
.practice-areas h1 {
font-weight: 600;
font-size: 60px;
font-family: 'Open Sans Condensed';
text-transform: uppercase;
color: #ffffff;
line-height: 35px;
margin-bottom: 10px;
margin-top: 0;
text-align: right;
-webkit-font-smoothing: antialiased;
}

.practice-areas h5 {
text-transform: uppercase;
color: #ffffff;
font-family: 'Open Sans Condensed';
margin-top: 0;
margin-bottom: 0;
text-align: left;
-webkit-font-smoothing: antialiased;
}

.practice-areas p {
font-family: 'Open Sans Condensed';
font-size: 20px;
line-height: 20px;
text-transform: uppercase;
margin-bottom: 0;
text-align: right;
color: #ffffff;
-webkit-font-smoothing: antialiased;
}

.practice-areas .result {
color: #f6f6f6;
font-size: 16px;
}

.practice-areas .square-1 {
background-image: url("https://placeholdit.imgix.net/~text?txtsize=33&w=350&h=150");
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height: 300px;
}

.practice-areas .square-2 {
background-image: url("https://placeholdit.imgix.net/~text?txtsize=33&w=350&h=150");
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height: 300px;
}

.practice-areas .square-3 {
background-image: url("https://placeholdit.imgix.net/~text?txtsize=33&w=350&h=150");
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height: 300px;
}

.practice-areas .square {
bottom: 20px;
display: table;
left: 0;
position: absolute;
width: 100%;
}

.practice-areas .square-1,
.practice-areas .square-2,
.practice-areas .square-3 {
-webkit-transition: background-color 0.3s ease-in-out 0s;
-o-transition: background-color 0.3s ease-in-out 0s;
-moz-transition: background-color 0.3s ease-in-out 0s;
transition: background-color 0.3s ease-in-out 0s;
}

.practice-areas .square-1:hover, .practice-areas .square-1:focus,
.practice-areas .square-2:hover,
.practice-areas .square-2:focus,
.practice-areas .square-3:hover,
.practice-areas .square-3:focus {
background-color: #FAE2E1;
background-image: none;
}

.practice-areas .square-1 .left,
.practice-areas .square-1 .right,
.practice-areas .square-2 .left,
.practice-areas .square-2 .right,
.practice-areas .square-3 .left,
.practice-areas .square-3 .right {
display: table-cell;
height: auto;
text-align: center;
padding-left: 15px;
padding-right: 15px;
vertical-align: top;
width: 50%;
}

.practice-areas .square-1 .left,
.practice-areas .square-2 .left,
.practice-areas .square-3 .left {
border-right: 1px solid #ffffff;
}

.practice-areas .square-1 .right,
.practice-areas .square-2 .right,
.practice-areas .square-3 .right {
border-left: 1px solid #ffffff;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row practice-areas">
<div class="col-sm-4 square-1">
<div class="square">
<div class="left">
<h1 class="amount">$90.2</h1>
<p class="million">million</p>
<p class="result">text</p>
</div>
<div class="right">
<h5 class="case">COMPANY NAME</h5>
</div>
</div>
</div>
<div class="col-sm-4 square-2">
<div class="square">
<div class="left">
<h1 class="amount">$90.2</h1>
<p class="million">million</p>
<p class="result">text</p>
</div>
<div class="right">
<h5 class="case">COMPANY NAME</h5>
</div>
</div>
</div>
<div class="col-sm-4 square-3">
<div class="square">
<div class="left">
<h1 class="amount">$90.2</h1>
<p class="million">million</p>
<p class="result">text</p>
</div>
<div class="right">
<h5 class="case">COMPANY NAME</h5>
</div>
</div>
</div>
</div>
</div>

关于html - 使用 Bootstrap 平衡图像的文本叠加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41879470/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com