【问题标题】:Div Cards OverlappingDiv 卡重叠
【发布时间】:2020-02-16 15:58:34
【问题描述】:

Div 当我将屏幕尺寸缩小到一定程度时,卡会相互重叠。但是在我进一步减少它之后,它会按我想要的方式工作。这就是当我将其简化为引导程序可以在col-md上工作时的样子@

这是个问题

这是正常的:

.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>

【问题讨论】:

  • 这是由于“figure”标签中的固定宽度(265px),使宽度为“100%”或“auto”。请尝试一下。
  • aah 感谢您的帮助和一些修改并解决了我的问题 :)

标签: javascript html css bootstrap-4


【解决方案1】:

我看到了你的 sn-p,我注意到你在 CSS (265px) 中为“figure”标签提供了固定宽度值。因此,它会导致列父 div 上的覆盖。只需用“auto”更新宽度或使其“100%”,我希望它会解决。我在下面添加了更新的sn-p,请尝试一下。

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}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-06
    • 2010-10-17
    • 2020-04-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多