我正在开发一个项目,点击时div的高度会增加,我只希望那个下方的div向下移动而不是整行...
现在我点击时div的高度越来越高,但无法弄清楚如何正确设置它以使整个下面的行不会向下移动。
.section-container {
max-width: 1280px;
margin: 0 auto;
}
.job-title {
text-align: center;
padding: 25px;
background: #444;
margin-bottom: 0;
}
.job-title-container {
position: relative;
}
.job-information-container {
background: #888;
margin-top: 0;
padding: 25px;
display: none;
}
.job-information-container p {
margin-top: 0;
}
.job-plus-icon {
position: absolute;
left: -webkit-calc(50% - 15px);
bottom: -webkit-calc(0% - 15px);
left: calc(50% - 15px);
bottom: calc(0% - 15px);
width: 30px;
transition: transform 0.3s;
}
.to-open {
-webkit-transform: rotate(135deg);
-moz-transform: rotate(135deg);
-ms-transform: rotate(135deg);
-o-transform: rotate(135deg);
transform: rotate(135deg);
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-vdeg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
}
.to-close {
-webkit-transform: rotate(135deg);
-moz-transform: rotate(135deg);
-ms-transform: rotate(135deg);
-o-transform: rotate(135deg);
transform: rotate(135deg);
}
有任何帮助吗?
答案 0 :(得分:1)
您需要将其设为3列,然后将要堆叠的列放在一起
https://codepen.io/anon/pen/BJNRpO
$('.job-title-container').click(function(){
$(this).next().slideToggle();
if ($(this).children('.job-plus-icon').hasClass('to-close')) {
$(this).children('.job-plus-icon').removeClass('to-close').addClass('to-open');
} else {
$(this).children('.job-plus-icon').removeClass('to-open').addClass('to-close');
}
})
body {
color: #fff;
}
.section-container {
max-width: 1280px;
margin: 0 auto;
}
.job-title {
text-align: center;
padding: 25px;
background: #444;
margin-bottom: 0;
}
.job-title-container {
position: relative;
}
.job-information-container {
background: #888;
margin-top: 0;
padding: 25px;
display: none;
}
.job-information-container p {
margin-top: 0;
}
.job-plus-icon {
position: absolute;
left: -webkit-calc(50% - 15px);
bottom: -webkit-calc(0% - 15px);
left: calc(50% - 15px);
bottom: calc(0% - 15px);
width: 30px;
transition: transform 0.3s;
}
.to-open {
-webkit-transform: rotate(135deg);
-moz-transform: rotate(135deg);
-ms-transform: rotate(135deg);
-o-transform: rotate(135deg);
transform: rotate(135deg);
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-vdeg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
}
.to-close {
-webkit-transform: rotate(135deg);
-moz-transform: rotate(135deg);
-ms-transform: rotate(135deg);
-o-transform: rotate(135deg);
transform: rotate(135deg);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<div class="section-container">
<div class="row">
<div class="col-xs-12 col-md-4 job-container">
<div class="job-title-container">
<h1 class="job-title">Job Title</h1>
<img class="job-plus-icon" src="https://image.flaticon.com/icons/png/512/60/60740.png"/>
</div>
<div class="job-information-container">
<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use .</p>
</div>
<div class="job-title-container">
<h1 class="job-title">Job Title2</h1>
<img class="job-plus-icon" src="https://image.flaticon.com/icons/png/512/60/60740.png"/>
</div>
<div class="job-information-container">
<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
</div>
</div>
<div class="col-xs-12 col-md-4 job-container">
<div class="job-title-container">
<h1 class="job-title">Job Title3</h1>
<img class="job-plus-icon" src="https://image.flaticon.com/icons/png/512/60/60740.png"/>
</div>
<div class="job-information-container">
<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters.</p>
</div>
<div class="job-title-container">
<h1 class="job-title">Job Title4</h1>
<img class="job-plus-icon" src="https://image.flaticon.com/icons/png/512/60/60740.png"/>
</div>
<div class="job-information-container">
<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
</div>
</div>
<div class="col-xs-12 col-md-4 job-container">
<div class="job-title-container">
<h1 class="job-title">Job Title5</h1>
<img class="job-plus-icon" src="https://image.flaticon.com/icons/png/512/60/60740.png"/>
</div>
<div class="job-information-container">
<p>Many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
</div>
<div class="job-title-container">
<h1 class="job-title">Job Title6</h1>
<img class="job-plus-icon" src="https://image.flaticon.com/icons/png/512/60/60740.png"/>
</div>
<div class="job-information-container">
<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident.</p>
</div>
</div>
</div>
</div>
答案 1 :(得分:1)
您的.job-container
相对定位,因此所有.job-container
div都会增长以填充可用空间。当您展开顶部中间的那个(例如)时,该“行”中的其他人(不是实际的div.row
)会扩展相同的数量以填充新的可用空间。
如果你在每列中创建3列,每列2 job-container
,你应该能够实现你想要的 - 但是如果你有20 job-container
而不是6,那么你将会必须手动确定哪个job-container
进入哪个div。