Как получить содержимое под загрузочной картой при использовании положения относительно - PullRequest
0 голосов
/ 26 октября 2018

Я создаю загрузочную карту с изображением. Тело карты перемещается на изображение с помощью position: absolute и top.

Когда я добавляю новый div под карточку, div добавляется к изображению. Мне нужно, чтобы содержимое оставалось под телом карты.

Надеюсь, в этом есть смысл, но чтобы устранить путаницу, пожалуйста, ознакомьтесь с jsfiddle . Если вам нужна дополнительная информация, дайте мне знать.

Вот изображение этой дилеммы: enter image description here

1 Ответ

0 голосов
/ 26 октября 2018

Просто удалите 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>

Вы можете проверить это здесь также.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...