Родитель Sub Block Toggle имеет переменную высоту. При нажатии на кнопку Sub Block Toggle блок Lorem Ipsum должен уменьшаться и расширяться в зависимости от высоты слева.Высота анимированного элемента-сиблинга на основе высоты анимации элемента
Sub Block не может иметь цвет фона, так что это не вопрос простого перекрытия Lorem Ipsum с фоном Sub Block.
Это оставляет меня с анимацией высоты текста Lorem Impsum, но поскольку высота Sub Block является переменной, а onload - скрытой, я не могу использовать scrollHeight.
Любой может указать мне в правильном направлении?
Большое значение.
$('.footer-subblock-title').on('click', function(el) {
console.log('clicked');
$(this).next().animate({
height: ["toggle", "swing"]
});
});
* {
margin: 0;
padding: 0;
}
.body {
width: 500px;
height: 800px;
background: #bae0c4;
position: relative;
font: 14px/1.65em Arial;
}
.body .container {
top: 30px;
position: absolute;
left: 20%;
width: 80%;
}
.body .container .footer-block {
border: 2px solid #000;
bottom: -40px;
position: absolute;
left: 0;
width: 100%;
}
.body .container .footer-subblock {
overflow: hidden;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div class="body">
<div class="container">
<h3 class="title">
Title Goes Here
</h3>
<div class="text">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="footer-block">
<h4 class="footer-subblock-title">
Sub Block Toggle
</h4>
<div class="footer-subblock" style="display:none;">
Lorem Ipsum is simply dummy text
<br/>Lorem Ipsum is simply dummy text
<br/>Lorem Ipsum is simply dummy text
</div>
</div>
</div>
</div>
https://jsfiddle.net/32dk3txg/
Я не понял. вы хотите показать «субблок», не мешая другому тексту? Или вы хотите, чтобы другой текст сжимался по высоте, чтобы он не касался «субблока»? –
@zero point - это в основном оба. Высота текста должна уменьшаться при увеличении высоты субблока. Но поскольку у субблока нет фона, я не могу просто быть доволен перекрытием, заботящимся о скрытии текста. –
@zero point - другой текст должен сжиматься по высоте, чтобы он не касался субблока. –