【发布时间】:2020-09-03 14:45:29
【问题描述】:
我有一个带有输入字段的简单表单。现在在笔记本电脑屏幕上,输入的宽度占屏幕的 30%,这是正确的。
但是,我想做的是,如果设备的宽度为 600 像素或更小(移动设备),则将宽度增加到 60%。
问题在于它没有改变移动设备的宽度。似乎它在移动设备上仅占 30%,而不是 60%。我不确定自己在做什么不正确,因为我正在使用基于研究的@media 标签。
<section id="marketing-email">
<form class="marketing-email-form" method="post" action="https://metis-online.com/marketing-email.php">
<div>
<label for="email"><b>Be part of our mailing list to receive exclusive promotional offers on our courses and services:</b></label><br/>
<input type="email" id="market-email" name="market-email" required placeholder="Email"/>
<button type="submit" class="marketing-btn">Send</button>
</div>
</form>
</section>
@media only screen and (max-width: 600px) {
#market-email{
width:60%;
}
}
/*--------Marketing Email-------*/
#marketing-email{
padding: 1em;
width:100%;
text-align:center;
}
#market-email{
padding: 0.5em;
width:30%;
}
.marketing-btn{
background: #1034A6;
color:white;
padding: 0.5em;
}
【问题讨论】:
-
CSS 中的顺序很重要!目前,文档中稍后出现的样式会覆盖之前的设置。请参阅我的答案以获得解决方案。