需要将DIV-2粘贴在DIV-1的底部,然后将其悬停在DIV-1下

时间:2018-09-07 10:07:14

标签: html css twitter-bootstrap

我有点迷失在这里。

我希望我的.div .sticker位于stick-to-me上.div hover的底部

我尝试了几种方法,但从未获得过理想的结果。 主要问题是,当stick-to-me div悬停时,它会以某种方式将.sticker div向下推,而仅将其部分隐藏。

您可以在此fiddle中看到我的代码以及现在的代码。我没有得到想要的结果,这是显而易见的。

任何帮助或建议都很好。

这是我的html

.flex-row {
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
}

.flex-row:after,
.flex-row:before {
  display: none;
}

@media (max-width: 767px) {
  .flex-row {
    display: block;
  }
}


/* partners */

.mag-block {
  padding: 7px 0 120px;
}

@media (max-width: 991px) {
  .mag-block {
    padding-bottom: 60px;
  }
}

@media (max-width: 767px) {
  .mag-block {
    padding-bottom: 40px;
  }
}

.mag-block .row {
  margin-left: -8px;
  margin-right: -8px;
}

.mag-block .row [class^="col-"] {
  padding-left: 8px;
  padding-right: 8px;
}

@media (max-width: 991px) {
  .mag-block .row [class^="col-"] {
    padding-bottom: 16px;
  }
}

.mag-block .item {
  background-color: #fff;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  border: 1px solid #d5d2d2;
  text-decoration: none !important;
  -webkit-flex-direction: column;
  -moz-flex-direction: column;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  -moz-justify-content: center;
  justify-content: center;
  height: 137px;
  text-align: center;
  color: inherit;
}

.mag-block .item figcaption {
  font-size: 16px;
  line-height: 24px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 2px 10px 8px;
}

@media (max-width: 1219px) {
  .mag-block .item figcaption {
    font-size: 14px;
  }
}

@media (max-width: 991px) {
  .mag-block .item figcaption {
    font-size: 16px;
  }
}

@media (max-width: 767px) {
  .mag-block .item figcaption {
    font-size: 14px;
  }
}

.mag-block .item .logo {
  height: 50px;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  -moz-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  -moz-justify-content: center;
  justify-content: center;
}

.mag-block .item .logo img {
  display: inline-block;
  vertical-align: top;
  max-height: 100%;
  max-width: 100%;
}

.mag-block .item .logo .text {
  display: block;
  font-size: 30px;
  line-height: 34px;
  font-weight: 500;
  padding: 14px 0 0;
}

.mag-block .item .more-link {
  width: 142px;
  margin-left: auto;
  margin-right: auto;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  height: 0;
  overflow: hidden;
  -webkit-transition: all ease 0.3s;
  -o-transition: all ease 0.3s;
  transition: all ease 0.3s;
  margin-top: -5px;
}

.mag-block .item .more-link span {
  display: block;
  padding: 7px 0 3px;
  border-top: 2px solid lightgray;
}

.mag-block .item .more-link span:before {
  content: '+ ';
  color: #c2002d;
  display: inline-block;
  vertical-align: top;
  margin-left: -20px;
  padding-right: 4px;
}

.mag-block .item:hover {
  margin: -11px -8px;
  height: 200px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.mag-block .item:hover .more-link {
  height: 50px;
}

.stick-to-me {
  position: relative;
  padding-bottom: 50px;
  z-index: 500;
}

.sticker {
  position: absolute;
  bottom: 0;
  height: 50px;
  z-index: -500;
  background-color: #eee;
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<div class="container">
  <div class="mag-block">
    <div class="row flex-row">
      <div class="col-md-3 col-sm-6 stick-to-me">

        <a href="#" class="item">
          <figure>
            <div class="logo">
              <strong class="text">Partner 1</strong>
            </div>
            <figcaption>small text about Partner 1 </figcaption>
          </figure>


          <footer class="more-link">
            <span>Open</span>
          </footer>

        </a>

        <div class="sticker">
          <p> Sticker </p>
        </div>

      </div>
      <!-- stick to me ends -->
      <div class="col-md-3 col-sm-6 stick-to-me">
        <a href="#" class="item">
          <figure>
            <div class="logo">
              <strong class="text">Partner 2</strong>
            </div>
            <figcaption> tagline Partner 2</figcaption>
          </figure>
          <footer class="more-link">
            <span>Open</span>
          </footer>
        </a>

        <div class="sticker">
          <p> Sticker </p>
        </div>


      </div>
      <!-- stick to me ends -->

      <div class="col-md-3 col-sm-6 stick-to-me">
        <a href="#" class="item">
          <figure>
            <div class="logo">
              <strong class="text">Partner 3</strong>
            </div>
            <figcaption>tagline Partner 3</figcaption>
          </figure>
          <footer class="more-link">
            <span>Open</span>
          </footer>
        </a>

        <div class="sticker">
          <p> Sticker </p>
        </div>

      </div>
      <!-- stick to me ends -->


      <div class="col-md-3 col-sm-6 stick-to-me">
        <a href="#" class="item">
          <figure>
            <div class="logo">
              <strong class="text">Partner 4</strong>
            </div>
            <figcaption>tagline Partner 4</figcaption>
          </figure>
          <footer class="more-link">
            <span>Open</span>
          </footer>
        </a>

        <div class="sticker">
          <p> Sticker </p>
        </div>

      </div>
      <!-- stick to me ends -->
    </div>
  </div>
  <!-- mag-block -->

2 个答案:

答案 0 :(得分:1)

我简短地看了一下您的代码,我的建议是在您的CSS中添加这行代码。我在您的小提琴中进行了编辑,并且有效。我相信它接近您的需求。

如果需要,我可以在下班后对此答案添加更多细节。

 .stick-to-me:hover{
        padding-bottom: 0px;
        }

答案 1 :(得分:0)

您应该尝试这个

_context.MainTable
.Include(mt => mt.ChildTable1)
.Include(mt => mt.ChildTable1.ChildTable2)
.Include(mt => mt.ChildTable3)
.Include(mt => mt.ChildTable3.ChildTable4)
.SingleOrDefault(
        mt =>
        mt.ChildTable3.ChildTable4.Id == id 
        &&
        mt.ChildTable1.Operation == operation
        && 
        mt.ChildTable1.Method = method
        && 
        mt.StatusId == statusId);

它将为您工作。