简体   繁体   English

如何使表单字段响应?

[英]How do i make the form field responsive?

I have just started to learn django few weeks.我刚开始学习 django 几周。 To learn more effectively i have started to build a hotel website and deployed using heroku.为了更有效地学习,我开始构建一个酒店网站并使用 heroku 进行部署。 The website seems better on mine laptop but looks worse on my ipad or mobile.该网站在我的笔记本电脑上看起来更好,但在我的 ipad 或手机上看起来更糟。 I wanted to make the form fields reponsive using css or django crispy form.我想使用 css 或 django 脆皮表单使表单字段具有响应性。 I have found a lot of answers but none of them help me understand how to do it.我找到了很多答案,但没有一个能帮助我理解如何去做。 Also any further recommendation for the website would be recommended for me as a beginner in web development.此外,作为 Web 开发初学者,我还会向我推荐对该网站的任何进一步推荐。 Here is the website: https://hotel-jumera.herokuapp.com (Its mine practise for building website, so sorry for in case copyright issue) form field in template:这是网站: https : //hotel-jumera.herokuapp.com (我的网站建设实践,如有版权问题,请见谅)模板中的表单字段:

<form  method='post'>
    {% csrf_token %}
    {{booking_form.as_p }}
    <button type="submit" class="btn btn-success"> Send </button>
</form>

What you want to do is set some break points in your css where you can change the width of elements on your site您想要做的是在您的 css 中设置一些断点,您可以在其中更改站点上元素的宽度

@media only screen and (min-width: 400px) {
  .col-2 {
      background-color: red;
  }
}

If the browser window is 600px or bigger, the background color will be red.如果浏览器窗口为 600px 或更大,背景颜色将为红色。 This is a mobile first approach.这是移动优先的方法。 You build your site for mobile and then add breakpoints to cater for larger screens tablet min-width: 600px and desktop min-width: 1200px您为移动设备构建网站,然后添加断点以适应更大屏幕tablet min-width: 600pxdesktop min-width: 1200px

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM