html - CSS 使用媒体查询改变位置
问题描述
嗨,可以请人帮助我,我正在打破我的大脑,试图将 div 的位置从绝对更改为static(default)
我需要当页面缩小到800px
高于div(absolute)
另一个时,div(relative)
将他的位置更改为堆栈下方,div(relative)
但问题是我无法更改某些代码,因为我展示了一张幻灯片,而这张幻灯片保留了一张aspect ratio 16:9
图片,这就是为什么我使用 atop-padding 52.5
来始终保持这个纵横比,而图片保持他的原始外观我只需要上面有文字的潜水图片堆叠在图片结束的右下方或图片的 div 结束的地方
*{
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%;
}
.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{
position: relative;
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;
}
.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;
display: inline-block;
transition: background-color 0.6s ease;
}
.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;
}
}
解决方案
对于响应式媒体查询(当屏幕最大小于 800px 时有效)
@media (max-width: 800px){
.yourClassName{
//style goes here
}
}
访问以引用 css flex 框https://www.youtube.com/watch?v=0e02dl66PYo?
推荐阅读
- react-native - Button 中的文本不显示 ios 中的文本(本机基础)
- ajax - 使用钩子在按钮 onClick 事件时反应 ajax 调用
- visual-studio-2019 - 我怎么能关掉这个?视觉工作室 2019
- php - 为什么我使用 PHP cURL 的 GET 请求返回一个空白页?
- javascript - JS Visibility API - 切换到另一个应用程序窗口
- windows - 适用于 Windows 的 Docker。无法连接到 nginx
- node.js - docker 容器中的 Npm 安装找不到我的自定义注册表
- python - 通过 python subprocess ssh 在远程机器上运行 GUI 程序
- android - 如何使用 Material Design 主题制作圆形按钮?
- rest - Apache Ignite:可以将自定义 Rest Method 部署到服务网格