如何显示块的最后一部分的弹性?
How to display block the last part of flex?
让我把reactstrap做个样品。如果想在输入后添加提示文本怎么办。我怎样才能防止 p 标签采用内联格式?
如果我有输入组并且有一个
<p class="text-muted mb-0" style="
display: block;
">アエイオウ</p>
在最后一部分。我怎样才能让它成为一个新行的 p 标签?
像这样:
.input-group {
position: relative;
display: flex;
flex-wrap: wrap;
align-items: stretch;
width: 100%;
}
.input-group-prepend, .input-group-append {
display: flex;
}
.input-group > .input-group-prepend > .input-group-text {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.input-group-text {
display: -ms-flexbox;
display: flex;
align-items: center;
padding: 0.375rem 0.75rem;
margin-bottom: 0;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
text-align: center;
white-space: nowrap;
border: 1px solid #ced4da;
border-radius: 0.25rem;
}
.input-group > .form-control {
position: relative;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
width: 1%;
min-width: 0;
margin-bottom: 0;
}
.form-control {
display: block;
width: 100%;
padding: 0.375rem 0.75rem;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: 0.25rem;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
<div class="input-group"><div class="input-group-prepend"><span class="input-group-text">@</span></div><input type="text" placeholder="username" class="form-control"><p class="text-muted mb-0" style="
display: block;
">アエイオウ</p></div>
从 .input-group
class 中取出 <p>
。
通过这样做,<p>
将默认为全宽。
.input-group {
position: relative;
display: flex;
flex-wrap: wrap;
align-items: stretch;
width: 100%;
}
.input-group-prepend,
.input-group-append {
display: flex;
}
.input-group>.input-group-prepend>.input-group-text {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.input-group-text {
display: -ms-flexbox;
display: flex;
align-items: center;
padding: 0.375rem 0.75rem;
margin-bottom: 0;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
text-align: center;
white-space: nowrap;
border: 1px solid #ced4da;
border-radius: 0.25rem;
}
.input-group>.form-control {
position: relative;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
width: 1%;
min-width: 0;
margin-bottom: 0;
}
.form-control {
display: block;
width: 100%;
padding: 0.375rem 0.75rem;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: 0.25rem;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">@</span>
</div>
<input type="text" placeholder="username" class="form-control">
</div>
<!-- take the p tag out of input-group -->
<p class="text-muted mb-0 small">アエイオウ</p>
编辑:
如果您无法更改 HTML 而您 必须 使用 CSS,您也可以使用 flex-basis
p 元素.
像这样-
.input-group {
position: relative;
display: flex;
flex-wrap: wrap;
align-items: stretch;
width: 100%;
}
.input-group-prepend,
.input-group-append {
display: flex;
}
.input-group>.input-group-prepend>.input-group-text {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.input-group-text {
display: -ms-flexbox;
display: flex;
align-items: center;
padding: 0.375rem 0.75rem;
margin-bottom: 0;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
text-align: center;
white-space: nowrap;
border: 1px solid #ced4da;
border-radius: 0.25rem;
}
.input-group>.form-control {
position: relative;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
width: 1%;
min-width: 0;
margin-bottom: 0;
}
.form-control {
display: block;
width: 100%;
padding: 0.375rem 0.75rem;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: 0.25rem;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.text-muted {
flex-basis: 100%;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">@</span>
</div>
<input type="text" placeholder="username" class="form-control">
<p class="text-muted mb-0 small">アエイオウ</p>
</div>
https://jsfiddle.net/xj3fh4bk/6/
您的 html 代码应该是这样的:
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">@</span>
</div>
<input type="text" placeholder="username" class="form-control">
</div>
<p class="text-muted mb-0" style="display: block;">アエイオウ</p>
由于 .input-group
显示 属性 个 flex
,其子项将始终排成一行。所以,你应该在 .input-group
之外使用 p
标签
让我把reactstrap做个样品。如果想在输入后添加提示文本怎么办。我怎样才能防止 p 标签采用内联格式?
如果我有输入组并且有一个
<p class="text-muted mb-0" style="
display: block;
">アエイオウ</p>
在最后一部分。我怎样才能让它成为一个新行的 p 标签? 像这样:
.input-group {
position: relative;
display: flex;
flex-wrap: wrap;
align-items: stretch;
width: 100%;
}
.input-group-prepend, .input-group-append {
display: flex;
}
.input-group > .input-group-prepend > .input-group-text {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.input-group-text {
display: -ms-flexbox;
display: flex;
align-items: center;
padding: 0.375rem 0.75rem;
margin-bottom: 0;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
text-align: center;
white-space: nowrap;
border: 1px solid #ced4da;
border-radius: 0.25rem;
}
.input-group > .form-control {
position: relative;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
width: 1%;
min-width: 0;
margin-bottom: 0;
}
.form-control {
display: block;
width: 100%;
padding: 0.375rem 0.75rem;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: 0.25rem;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
<div class="input-group"><div class="input-group-prepend"><span class="input-group-text">@</span></div><input type="text" placeholder="username" class="form-control"><p class="text-muted mb-0" style="
display: block;
">アエイオウ</p></div>
从 .input-group
class 中取出 <p>
。
通过这样做,<p>
将默认为全宽。
.input-group {
position: relative;
display: flex;
flex-wrap: wrap;
align-items: stretch;
width: 100%;
}
.input-group-prepend,
.input-group-append {
display: flex;
}
.input-group>.input-group-prepend>.input-group-text {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.input-group-text {
display: -ms-flexbox;
display: flex;
align-items: center;
padding: 0.375rem 0.75rem;
margin-bottom: 0;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
text-align: center;
white-space: nowrap;
border: 1px solid #ced4da;
border-radius: 0.25rem;
}
.input-group>.form-control {
position: relative;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
width: 1%;
min-width: 0;
margin-bottom: 0;
}
.form-control {
display: block;
width: 100%;
padding: 0.375rem 0.75rem;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: 0.25rem;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">@</span>
</div>
<input type="text" placeholder="username" class="form-control">
</div>
<!-- take the p tag out of input-group -->
<p class="text-muted mb-0 small">アエイオウ</p>
编辑:
如果您无法更改 HTML 而您 必须 使用 CSS,您也可以使用 flex-basis
p 元素.
像这样-
.input-group {
position: relative;
display: flex;
flex-wrap: wrap;
align-items: stretch;
width: 100%;
}
.input-group-prepend,
.input-group-append {
display: flex;
}
.input-group>.input-group-prepend>.input-group-text {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.input-group-text {
display: -ms-flexbox;
display: flex;
align-items: center;
padding: 0.375rem 0.75rem;
margin-bottom: 0;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
text-align: center;
white-space: nowrap;
border: 1px solid #ced4da;
border-radius: 0.25rem;
}
.input-group>.form-control {
position: relative;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
width: 1%;
min-width: 0;
margin-bottom: 0;
}
.form-control {
display: block;
width: 100%;
padding: 0.375rem 0.75rem;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: 0.25rem;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.text-muted {
flex-basis: 100%;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">@</span>
</div>
<input type="text" placeholder="username" class="form-control">
<p class="text-muted mb-0 small">アエイオウ</p>
</div>
https://jsfiddle.net/xj3fh4bk/6/
您的 html 代码应该是这样的:
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">@</span>
</div>
<input type="text" placeholder="username" class="form-control">
</div>
<p class="text-muted mb-0" style="display: block;">アエイオウ</p>
由于 .input-group
显示 属性 个 flex
,其子项将始终排成一行。所以,你应该在 .input-group
p
标签