我想绘制一条线并确保线条调整大小以适应屏幕尺寸,并且线条点应始终坚持段落。像这样:
有没有办法添加这条线,所以它会一直指向div
?我进行了一项小型研究,发现使用border-right: 1px solid #000000;
用于列表,我如何才能对div
执行相同操作?
这是我的代码:
.jumbotron {
/* background-color: #353535;*/
/* background-image: url("https://unsplash.it/1440/736/?random");*/
background-size: cover;
color: #fff;
/* padding: 155px 25px;*/
padding-bottom: 200px;
font-family: Montserrat, sans-serif;
}
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<div class="container">
<div class="jumbotron text-center">
<h1>company name </h1>
<div calss="line" style=" border-bottom: 5px solid #000000;">
<div class="col-sm-6">
<h2 class="usertype">For Businesses</h2>
<p> Authentication .</p>
<a href="#" class="btn btn-default">Try It Now</a>
</div>
<div class="col-sm-6">
<h2 class="usertype">For Individuals</h2>
<p>For Google, Facebook, Coinbase .</p>
<a href="#" class="btn btn-default">Download App</a>
</div>
</div>
</div>
</div>
答案 0 :(得分:1)
以下是示例。请看看
* {
box-sizing: border-box;
}
body {
background: #fff;
}
.intro {
position: relative;
}
.main-heading:before {
width: 5px;
position: absolute;
left: 50%;
bottom: 0;
height: 20px;
background: #000;
content: '';
transform: translate(-50%, 0);
}
.main-heading {
text-align: center;
font-size: 30px;
line-height: 30px;
position: relative;
padding-bottom: 25px;
border-bottom: 5px solid #000;
}
.two-col:after {
display: block;
clear: both;
content: '';
}
.two-col .col {
float: left;
width: 50%;
position: relative;
padding: 0 20px;
}
.sub-heading {
position: relative;
display: inline-block;
padding: 20px 0;
}
.sub-heading:before {
width: 10px;
position: absolute;
left: 50%;
top: 0;
height: 20px;
background: #000;
content: '';
transform: translate(-50%, 0);
}
.sub-heading:after {
position: absolute;
background: #fff;
top: -5px;
left: -9999px;
content: '';
right: 50%;
height: 25px;
}
.two-col .col:last-child {
text-align: right;
}
.two-col .col:last-child .sub-heading:after {
right: -9999px;
left: 50%;
}
<div class="intro">
<div class="main-heading">Company Name</div>
<div class="two-col">
<div class="col">
<div class="sub-heading">For Business</div>
</div>
<div class="col">
<div class="sub-heading">For Individuals</div>
</div>
</div>
</div>
这里也是小提琴链接https://jsfiddle.net/gafnk4rg/
答案 1 :(得分:0)
答案 2 :(得分:-1)
一种可能的解决方案:
:before
和:after
以制作垂直线。xs
内的行,因为菜单的样式设置方式是sm
开始。这是一个演示(单击“整页”按钮以查看效果):
.jumbotron {
background-size: cover;
color: #fff;
padding-bottom: 200px;
font-family: Montserrat, sans-serif;
}
.line {
border-bottom:4px solid #000000;
width:50%;
margin:auto auto;
position:relative;
}
.line:before {
content:"";
position:absolute;
top:-15px;
left:50%;
height:15px;
border-left:4px solid #000000;
}
.line:after {
content:"";
position:absolute;
top:0;
left:0;
border-left:4px solid #000000;
border-right:4px solid #000000;
width:100%;
height:20px;
}
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<div class="container">
<div class="jumbotron text-center">
<h1>company name </h1>
<div>
<div class="line hidden-xs"></div>
<div class="col-sm-6">
<h2 class="usertype">For Businesses</h2>
<p> Authentication .</p>
<a href="#" class="btn btn-default">Try It Now</a>
</div>
<div class="col-sm-6">
<h2 class="usertype">For Individuals</h2>
<p>For Google, Facebook, Coinbase .</p>
<a href="#" class="btn btn-default">Download App</a>
</div>
</div>
</div>
</div>