Я создаю загрузочную карту с изображением. Корпус карты перемещается на изображение с помощью position: absolute
и top
.
Когда я добавляю новый div под карточкой, он подталкивается к изображению. Мне нужно, чтобы содержимое оставалось под телом карты.
Надеюсь, это имеет смысл, но, чтобы устранить путаницу, ознакомьтесь с jsfiddle. Если вам нужна дополнительная информация, дайте мне знать.
Просто удалите стили position: absolute; top: 320px; left: 76px;
из правила .card-body и добавьте вместо них margin-top:-50px; margin-left: 50px;
.
.row {
background: #f8f9fa;
margin-top: 20px;
}
.col {
border: solid 1px #6c757d;
padding: 10px;
}
.card {
border: none;
}
.card-body {
width: 80%;
border: 1px solid rgba(0,0,0,.125);
border-radius: .25rem;
background: #fff;
/*position: absolute;
top: 320px;
left: 76px;*/
margin-top:-50px;
margin-left: 50px;
}
<script src = "https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel = "stylesheet"/>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href = "https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel = "stylesheet"/>
<!--
Bootstrap docs: https://getbootstrap.com/docs
-->
<div class = "container">
<div class = "card" style = "width: 100%;">
<img class = "card-img-top" src = "http://getbootstrap.com/docs/4.1/assets/brand/bootstrap-social.png" alt = "Card image cap">
<div class = "card-body">
<h5 class = "card-title">Card title</h5>
<p class = "card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href = "#" class = "btn btn-primary">Go somewhere</a>
</div>
</div>
</div>
<div>
I need this text to be underneath the card.I tried using margin-bottom for the card, but the problem with this is the content of the card body changed, therefore the height changes which is what i want.
</div>
Вы также можете протестировать его здесь.
Ты понял, приятель!
Не могу поверить, что не подумал об этом. Большое спасибо!