CSS使用保持宽高比的媒体查询来更改位置

时间:2018-10-23 00:31:53

标签: css responsive absolute relative

您好,请有人帮我,我正想将div的位置从绝对值更改为静态值(默认),我很伤脑筋,我需要在页面减小到800px时位于另一个div上方的div(绝对值)相对)将其位置更改为堆叠在div(relative)的下方,但问题是我无法更改某些代码,因为我显示了一张幻灯片,并且此幻灯片保持图片的纵横比为16:9,这就是为什么我使用顶部填充52.5可以始终保持此长宽比,并且图片保持其原始外观,我只需要具有图片上方文本的潜水在图片结束处或图片div结束处堆叠在右下方

https://jsfiddle.net/nackt7jq/9/

*{
  margin:0;
  padding:0;
}
.navi{
  background:yellow;
  width:100%;
  height:100px;
  margin-bottom:20px;
}
.jumbo{
  background:grey;
  width:100%;
  height:500px;
  margin-top:20px;
}


.slideshow{
  background:green;
  width:100%;
  position: relative;  

}
.slide-image-wrap{
  width:100%;
  box-sizing: border-box;


}
.mySlides {
  width: 100%;
  overflow: hidden;
  }

img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  margin: auto;


}
#tata .slide-image-wrap .mySlides{
  height:0;
  padding-top: 56.25%;

}

#tata img{

  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}


.slide-text-wrap{
  height: 100px;
  width:500px;
  background:blue;
  position: absolute;
  bottom:20%;
  right: 6%;
  color:orange;
  font-size: 2em;
}



/* Next & previous buttons */
.prev, .next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: auto;
  padding: 16px;
  margin-top: -22px;
  color: white;
  font-weight: bolder;
  font-size: 2em;
  transition: 0.6s ease;
  border-radius: 0 3px 3px 0;

}

/* Position the "next button" to the right */
.next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

/* On hover, add a black background color with a little bit see-through */
.prev:hover, .next:hover {
  background-color: rgba(255,0,0,0.8);
}


/* The dots/bullets/indicators */
.dot {
  cursor: pointer;
  height: 10px;
  width: 20px;
  margin: 0 10px;
  background-color: #bbb;
  /* border-radius: 50%; */
  display: inline-block;
  transition: background-color 0.6s ease;
  /*position: absolute;*/
}

.active, .dot:hover {
  background-color: right:   ;
}
.fade {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 1.5s;
  animation-name: fade;
  animation-duration: 1.5s;
}




@media only screen and (orientation: portrait) {



}

@media only screen and (max-width: 800px){
  .slide-text-wrap{
  background-color: yellow;
  top: 0;
  right: 0;
  bottom:0%;
  left: 0;
  margin: auto auto 0 auto;
  width: 450px;
}


}

0 个答案:

没有答案