so i have a page that looks like this enter image description here

用这样的一个HTML

<form id="contact-form">
    <div class="row" style="position:relative">
        <div class="col-md-6">
            <input type="text" placeholder="First Name*" required id="firstName" />
        </div>
        <div class="col-md-6">
            <input type="text" placeholder="Last Name*" required id="secondName" />
        </div>
    </div>
    <div class="row">
        <div class="col-md-6">
            <input type="email" placeholder="Email*" required id="email" />

        </div>
        <div class="col-md-6">
            <input type="tel" placeholder="Phone Number*" required id="phoneNumber" />
        </div>
    </div>
    <div class="row">
        <div class="col">
            <textarea rows="3" placeholder="Message*" required id="message"></textarea>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <button type="submit" class="rehab-btn-secondary btn-send-contact">Send</button>

        </div>
    </div>
</form>

As seen above, there is a div which has a class "row" and the two div elements that contains the input for "First Name" and "Last name", same as "Email" as "Phone Number". This part is ok as I can set the margin-bottom for each "row" class to 15px and each row will have a gap. However, this approach is not responsive, as In mobile it will look like this enter image description here

内部元素是重叠的,我想不出一种方法来使这一响应,使"名字"和"姓氏"将在另一行与移动模式的空白. 我能只用纯的css和html来处理它吗?或者,如果它是在移动模式下,我需要用javascrip编写一些脚本吗?

有什么建议吗?

推荐答案

因为您使用的是Bootstrap,所以您可以使用它的类作为页边距,并仅为移动设备设置顶部页边距.

只需在"Last Name"和"Phone"输入中添加mt-3 mt-md-0个类:

<div class="col-md-6 mt-3 mt-md-0">
  <input type="text" placeholder="Last Name*" required id="secondName" />
</div>
...
<div class="col-md-6 mt-3 mt-md-0">
  <input type="tel" placeholder="Phone Number*" required id="phoneNumber" />
</div>

这将设置移动设备的利润率,并删除桌面设备的利润率.

Html相关问答推荐

Rmarkdown上的垂直标签集

如何在不影响子列表的情况下在HTML(OL Li)上同时加数字和列表?

未显示新组件的视图

CURL邮箱中的图像不能调整其大小

容器内的SVG图像没有响应

R-markdown中的非顺序列表

如何最大限度地减少Cookie同意代码对性能的影响?

当溢出到滚动条中时, bootstrap 按钮样式会更改

如何使用CSS在<;表格中<;SVG&>?

单独处理Button:Focus的多行按钮

Flexbox在元素之间造成了太大的差距

从html文件中提取元素的Python BeautifulSoup

如何使Bootstrap 5卡可点击

如何围绕中心zoom svg 并使父级达到其子级大小的 100%

屏幕缩小时背景图像裁剪高度

如何在 css 和 html 中创建花状 struct

重点/主动输入的概述问题

在 vscode 中找不到 htmltagwrap 命令

悬停一个 div 时更改所有其他 div 上的字体 colored颜色

为什么图像会影响我的