Перекрытие карт Div - PullRequest
       3

Перекрытие карт Div

0 голосов
/ 15 февраля 2020

Div Карты накладываются друг на друга, когда я уменьшаю размер экрана в определенной степени. Но после того, как я уменьшу его еще больше, все будет работать так, как я хочу. Вот как это выглядит, когда я уменьшаю его до такой степени, что bootstrap может работать на col-md

Это проблема

enter image description here

Вот как обычно это выглядит:

enter image description here

.cards {
  margin-top: 100px;
}

.cards h1 {
  text-align: center;
}

html {
  font-family: "Source Sans Pro", sans-serif;
  font-size: 16px;
  font-smooth: auto;
  font-weight: 300;
  line-height: 1.5;
  color: #444;
}

a {
  text-decoration: none;
}

figure {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 265px;
  height: 360px;
  margin-left: 25px;
  padding: 20px 20px;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  border-radius: 10px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  overflow: hidden;
}

figure:before,
figure:after {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

figure:before {
  content: "";
  background-color: rgba(0, 0, 0, 0.1);
  z-index: 0;
}

figure:after {
  content: "";
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  overflow: hidden;
}

figure:hover {
  background-size: 175%;
}

figure:hover:after {
  content: "read more";
  background-color: rgba(191, 191, 191, 0.9);
  color: white;
  font-size: 32px;
  z-index: 2;
}

figure:hover .date {
  bottom: -59px;
}

figure:hover figcaption {
  transform: translateY(-110%);
}

.cards p {
  display: none;
}

.cards p:hover {
  display: block;
  color: #999;
}

figure .date {
  position: absolute;
  bottom: 0;
  right: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 10px;
  background-color: rgba(241, 196, 15, 0.8);
  text-shadow: 1px 1px rgba(0, 0, 0, 0.7);
  transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

figure .date span {
  color: white;
  line-height: 1;
}

figure .date span:first-child {
  font-family: "Source Code Pro", sans-serif;
  font-size: 20px;
  font-weight: 900;
}

figure .date span:last-child {
  font-size: 14px;
  font-weight: 400;
}

figure figcaption {
  color: #333;
  text-align: center;
  transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  z-index: 1;
}

figure figcaption h4 {
  margin: 0 0 5px;
  font-family: "Source Code Pro", sans-serif;
  font-size: 24px;
  line-height: 1.35;
  text-shadow: 1px 1px rgba(0, 0, 0, 0.7);
}

figure figcaption h4>span {
  /* background-color: rgba(241, 196, 15, 0.8); */
}

figure figcaption p {
  margin: 0;
  line-height: 1.5;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="cards">
  <h1>What We Offer</h1>
  <div class="row">
    <div class="col-lg-3 col-md-6">
      <a class="" href="#">
        <figure style='background-image: url("offers/conference.jpg")'>
          <figcaption>
            <h4> <span>Conference halls</span></h4>
            <p></p>
          </figcaption>
        </figure>
      </a>
    </div>
    <div class="col-lg-3 col-md-6">
      <a class="" href="#">
        <figure style='background-image: url("offers/restaurant.jpg")'>
          <figcaption>
            <h4> <span>Restaurant & Bar</span></h4>
            <p></p>
          </figcaption>
        </figure>
      </a>
    </div>
    <div class="col-lg-3 col-md-6">
      <a class="" href="#">
        <figure style='background-image: url("offers/entertainment.jpg")'>
          <figcaption>
            <h4> <span>Entertainment room</span></h4>
            <p></p>
          </figcaption>
        </figure>
      </a>
    </div>
    <div class="col-lg-3 col-md-6">
      <a class="" href="#">
        <figure style='background-image: url("offers/spa.jpg")'>
          <figcaption>
            <h4> <span>Spa & Wellness</span></h4>
            <p></p>
          </figcaption>
        </figure>
      </a>
    </div>

  </div>
</div>

1 Ответ

0 голосов
/ 15 февраля 2020

Я видел ваш фрагмент, и я заметил, что вы дали фиксированное значение ширины тегу figure в CSS (265 пикселей). Из-за чего это вызывает наложение на столбец родительского div. Просто обновите ширину с помощью «auto» или сделайте «100%», я надеюсь, что это разрешится. Я добавил обновленный фрагмент ниже, пожалуйста, попробуйте.

figure {

position: relative;
display: flex;
align-items: flex-start;
justify-content: center;
width: 100%;
height: 360px;
margin-left: 25px;
padding: 20px 20px;
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
border-radius: 10px;
box-shadow: 0 14px 28px}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...