gpt4 book ai didi

html - col-md-6 在手机上没有响应

转载 作者:行者123 更新时间:2023-11-28 19:24:41 26 4
gpt4 key购买 nike

我在桌面上有以下部分,我需要在移动设备上制作图像在上方,橙​​色框在下方,但图像覆盖了所有内容。

桌面

DESKTOP

移动 how is doing in mobile

.second-section .box-orange {
background-image: url("/img/fundo2.png");
height: 400px;
color: white;
margin-top: 10%;
margin-bottom: 10%;
}

.second-section .box-orange img {
height: 550px;
margin-top: -10%;
margin-left: 2%;
object-fit: cover;
}

.second-section .box-orange h3 {
font-size: 2.5em;
margin-bottom: 5%;
}

.second-section .box-orange h3 .line {
font-size: 2.5em;
margin-bottom: 5%;
}

.second-section .box-orange p {
font-size: 2.5em;
margin-bottom: 5%;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">

<section class="second-section">
<div class="container">
<div class="row align-items-center box-orange">
<div class="col-md-6">
<img class="w-100" src="img/campos.png">
</div>
<div class="col-md-6 ml-5 ml-md-0 text-center">
<h3>lorem lorem! <div class="line"></div>
</h3>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Eum nulla quod alias odio perspiciatis architecto, possimus, aliquid repellendus totam, quos nihil similique. Laborum eaque ipsa beatae amet sapiente temporibus. Rerum.
</p>
</div>
</div>
</div>
</section>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>


我不知道我是否应该以不同的方式构建我的 CSS,或者做一些媒体想要保持我需要的方式。

需要在移动设备中保持这样。

mobile


添加媒体后,结果是这样的。

@media only screen and (max-width: 800px) {
.second-section img {
height: unset;
margin-left:unset;
}

.textdiv {
margin-left:0px;

}
}

result after media querie

最佳答案

HTML代码:

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="my.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<section class="second-section">
<div class="container">
<div class="row align-items-center box-orange">
<div class="col-md-6">
<img class="w-100" src="img.jpg">
</div>
<div class="col-md-6 ml-md-0 text-center textdiv">
<h3>lorem lorem! <div class="line"></div></h3>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Eum nulla quod alias odio perspiciatis architecto, possimus, aliquid repellendus totam, quos nihil similique. Laborum eaque ipsa beatae amet sapiente temporibus. Rerum.</p>
</div>
</div>
</div>
</section>
</body>
</html>

CSS:

我的.css:

.box-orange {
background-image: url("/img/fundo2.png");
height: 400px;
color: white;
margin-top: 10%;
margin-bottom: 10%;
}
.second-section img {
height: 550px;
margin-top: -10%;
margin-left: 2%;
object-fit: cover;
}
.second-section h3 {
font-size: 2.5em;
margin-bottom: 5%;
}
.second-section.line {
width: 80%;
border: 2px solid #77d3c2;
position: absolute;
left: 33%;
top: 100%;
}

.second-section p {
font-size: 1.4em;
padding: 0% 10%;
}
.textdiv {
margin-left: 3rem;
}

@media only screen and (max-width: 800px) {
.second-section img {
height: unset;
margin-left:unset;

}

.textdiv {
margin-left:0px;

}
}

因为您已经为图像指定了固定高度,并且相同的高度也适用于移动版本,为了解决这个问题,我添加了媒体查询

检查一下,它会起作用

关于html - col-md-6 在手机上没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56535219/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com