gpt4 book ai didi

html - CSS - 媒体查询无法正常运行

转载 作者:太空宇宙 更新时间:2023-11-04 05:43:13 25 4
gpt4 key购买 nike

在我的元素中,我有一个 div,我想在屏幕达到一定大小时移动它的位置。我尝试通过媒体查询来执行此操作,但是无论屏幕大小如何,表单仍然停留在一个位置。

这是我的代码:

.formContainer {
position: relative;
border: 1px solid #e0e0e0;
width: 400px;
height: 550px;
margin-left: 768px;
margin-top: 140px;
}

@media screen and (max-width: 1200px) {
.formContainer {
background-color: red;
}
}
<div class="formContainer">
....
</div>

HTML:

<div class="formContainer">
....
</div>

CSS:

.formContainer {
position: relative;
border: 1px solid #e0e0e0;
width: 400px;
height: 550px;
margin-left: 768px;
margin-top: 140px;
}

@media screen and (max-width: 1200px) {
.formContainer {
left: 10px;
}
}

更新:

@media screen and (max-width: 1200px) {
.formContainer {
left: -10000px;
}
}

更新 2:

@media screen and (max-width: 1200px) {
.formContainer {
background-color: red;
}
}

代码:

<div class="formContainer">
<div class="innerContainer">
</div>

<img class="test233" src="{% static 'mosque.png' %}" width="70px" style="position: relative; top: -75px; left: 60px;">
<span style="position: relative; top: -60px; left: 60px; font-size: 32px; font-family: serif;" class="innerText"> Islamagram </span>

<h2 style="position: relative; font-size: 21px;left:62px; font-family: sans-serif; color: #999999; top: -46px;">&nbsp;Sign up to view and share<br>life-changing islamic content.</h2>

<form class="form" method="post" autocomplete="off">
{% csrf_token %}
{% for field in form %}
{{ field }}
<br>
{% endfor %}
<button type="submit"class="btn btn-primary subButton"><span class="signupText">Sign Up</span></button>
</form>
{% if error1 %}
<span style="position: relative; color: red; font-size: 18px; left: 69px; top: 10px;">{{ error1 }}<span>
{% endif %}
{% if error2 %}
<span style="position: relative; color: red; font-size: 18px; left: 68px; top: 10px;">{{ error2 }}</span>
{% endif %}
{% if error3 %}
<span style="position: relative; color: red; font-size: 18px; left: 118px; top: 10px;">{{ error3 }}</span>
{% endif %}
{% if error4 %}
<span style="position: relative; color: red; font-size: 18px; left: 84px; top: 10px;">{{ error4 }}</span>
{% endif %}

有人知道这个问题吗?谢谢。

最佳答案

.formContainer {
position: relative;
border: 1px solid #e0e0e0;
width: 400px;
height: 550px;
margin-left: 768px;
margin-top: 140px;
}

@media screen and (max-width: 1200px) {
.formContainer {
left: -200px;
}
}

关于html - CSS - 媒体查询无法正常运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58962084/

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