bootstrap 4是否有内置的水平分隔线?我可以这样做,
<style type="text/css">
.h-divider{
margin-top:5px;
margin-bottom:5px;
height:1px;
width:100%;
border-top:1px solid gray;
}
</style>
但我想使用内置的bootstrap css,我无法在文档中的任何地方找到它,也许我错过了它。
答案 0 :(得分:59)
HTML已经有一个名为<hr/>
的内置水平分隔符(&#34;水平规则&#34;的缩写)。引导样式like this:
hr {
margin-top: 1rem;
margin-bottom: 1rem;
border: 0;
border-top: 1px solid rgba(0, 0, 0, 0.1);
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<p>Some text<hr/>More text<p>
&#13;
答案 1 :(得分:10)
对于Bootstrap 4
<hr>
仍适用于普通分频器。但是,如果您想要一个中间有文本的分隔符:
<div class="row">
<div class="col"><hr></div>
<div class="col-auto">OR</div>
<div class="col"><hr></div>
</div>
答案 2 :(得分:9)
在Bootstrap 4.0v
中<span class="border-top my-3"></span>
你可以将my-3改为my-2; m代表&#34; margin&#34;,y代表&#34; top和bottom&#34;
答案 3 :(得分:7)
对于下拉菜单,是:
https://v4-alpha.getbootstrap.com/components/dropdowns/
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Separated link</a>
</div>
答案 4 :(得分:3)
对于Bootstrap v4;
细线;
<div class="divider py-1 bg-dark"></div>
用于中等粗线;
<div class="divider py-1 bg-dark"><hr></div>
粗线;
exports.newUser = functions.firestore.document('users/{userId}')
.onCreate((snap, context) => {
const newUserNumber = snap.data().anglerNumber;
const anglersRef = admin.firestore().collection('anglerNumbers');
const snapshot = anglersRef.where('anglerNumber', '==', newUserNumber).get();
if (snapshot.empty) {
console.log('No matching documents.');
return;
}
snapshot.forEach(doc => {
console.log(doc.id, '=>', doc.data());
doc.delete();
});
})
答案 5 :(得分:2)
/*
*
* ==========================================
* CUSTOM UTIL CLASSES
* ==========================================
*
*/
hr.dashed {
border-top: 2px dashed #999;
}
hr.dotted {
border-top: 2px dotted #999;
}
hr.solid {
border-top: 2px solid #999;
}
hr.hr-text {
position: relative;
border: none;
height: 1px;
background: #999;
}
hr.hr-text::before {
content: attr(data-content);
display: inline-block;
background: #fff;
font-weight: bold;
font-size: 0.85rem;
color: #999;
border-radius: 30rem;
padding: 0.2rem 2rem;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
/*
*
* ==========================================
* FOR DEMO PURPOSES
* ==========================================
*
*/
body {
min-height: 100vh;
background-color: #fff;
color: #333;
}
.text-uppercase {
letter-spacing: .1em;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css">
<div class="container py-5">
<!-- For Demo Purpose -->
<header class="py-5 text-center">
<h1 class="display-4">Bootstrap Divider</h1>
<p class="lead mb-0">Some divider variants using <hr> element. </p>
<p class="font-weight-light mb-0">Snippet by <a href="https://bootstrapious.com" class="">
<u>Bootstrapious</u></a>
</p>
</header>
<div class="row">
<div class="col-lg-8 mx-auto">
<div class="mb-4">
<h6 class=" text-uppercase">Dashed</h6>
<!-- Dashed divider -->
<hr class="dashed">
</div>
<div class="mb-4">
<h6 class=" text-uppercase">Dotted</h6>
<!-- Dotted divider -->
<hr class="dotted">
</div>
<div class="mb-4">
<h6 class="text-uppercase">Solid</h6>
<!-- Solid divider -->
<hr class="solid">
</div>
<div class="mb-4">
<h6 class=" text-uppercase">Text content</h6>
<!-- Gradient divider -->
<hr data-content="AND" class="hr-text">
</div>
</div>
</div>
</div>
答案 6 :(得分:1)
<div class="dropdown">
<button data-toggle="dropdown">
Sample Button
</button>
<ul class="dropdown-menu">
<li>A</li>
<li>B</li>
<li class="dropdown-divider"></li>
<li>C</li>
</ul>
</div>
这是引导程序4中水平分隔线的示例代码。Output looks like this:
bootstrap 4中使用的
class =“ dropdown-divider”,而bootstrap 3中使用的class =“ divider”用于水平分隔器
答案 7 :(得分:1)
<div class="form-group col-12">
<hr>
</div>
答案 8 :(得分:1)
在 Bootstrap 5 中,您可以执行以下操作:
<div class="py-2 my-1 text-center position-relative mx-2">
<div class="position-absolute w-100 top-50 start-50 translate-middle" style="z-index: 2">
<span class="d-inline-block bg-white px-2 text-muted">or</span>
</div>
<div class="position-absolute w-100 top-50 start-0 border-muted border-top"></div>
</div>
答案 9 :(得分:0)
您可以使用mt
和mb
间距实用程序为<hr>
添加多余的边距,例如:
<hr class="mt-5 mb-5">
答案 10 :(得分:0)
Bootstrap 4还使用标记在文本下划线。但是我觉得必须有一些间距才能使其看起来不错。
答案 11 :(得分:0)
我在我的项目中使用以下示例:
html:
<hr class="my-3 dividerClass"/>
css:
.dividerClass{
border-top-color: #999
}