简体   繁体   English

当屏幕大于或等于 600px 宽(包括我的代码)时,如何使用媒体查询制作一个 600px 宽的表单?

[英]Using media queries how do I make a form that is 600px wide when the screen is greater than or equal to 600px wide (my code included)?

I'm thinking the following...我在想以下...

@media only screen and (min-width: 600px) {
.form {
width: 600px}
}

Am I correct?我对么?

You don't really need a media query for this.您真的不需要为此进行媒体查询。 If you set the width at 600px and a max-width to prevent it exceeding 100% it will work.如果您将宽度设置为 600px 和最大宽度以防止其超过 100%,它将起作用。

 form { width: 600px; max-width: 100%; margin: 0 auto; }
 <form> <fieldset> <legend>Example Form</legend> <div> <label>Name<br /><input type="text" name="name" /></label> </div> <div> <button>Submit</button> </div> </fieldset> </form>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用媒体查询,当屏幕宽度大于或等于 600 像素时,如何制作使用网格布局来布局标签和表单元素的表单? - With media query how do I make a form that uses grid layout to layout labels and form elements when the screen is greater than or equal to 600px wide? 当 window 宽于 600px 时,如何获得 600px 的表单元素? - How do I get a form element that is 600px when the window is wider than 600px? 仅当屏幕宽度小于 600px 时,使 div 从底部消失 850px - make div disappear 850px from bottom only when screen is less than 600px wide 使我的 2 个 div 在屏幕上堆叠小于 600px - Make my 2 divs stack on screen smaller than 600px 当我将屏幕尺寸调整为小于600像素时,媒体查询不起作用 - Media query doesn't work when i resize screen less than 600px 当 window 宽度等于 600px 时如何禁用 OverlayScrollbars? - How to disable OverlayScrollbars when window width equal 600px? CSS 项目帮助。 当 window 比 600px 宽时,页面需要有一个 600px 的“表单”元素,并且 - CSS Help for a project. Page needs to have a 'form' element that is 600px when the window is wider than 600px and 如何使此代码仅出现在 600 像素及以上? (我不希望它出现在手机或平板电脑上) - How do I make this code only appear for 600px and upwards? (I don't want it appearing on mobile or tablet) <a>屏幕分辨率低于600像素时</a>无法隐藏<a>标签</a> - cant hide an <a> tag when the screen resolution is below 600px CSS 图片卡/w Avatar 的边框问题,当 600 像素或更大时,我无法将卡与表单对齐 - CSS Border Issues with Picture Card/w Avatar and I Can't align card with form when 600px or Greater
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM