gpt4 book ai didi

html - 用 css 分隔表单

转载 作者:太空宇宙 更新时间:2023-11-04 09:16:03 26 4
gpt4 key购买 nike

我需要将一个表格分成两部分。一个站点上的 3 个字段和另一个字段上的另一个字段和提交按钮。除了按钮之外,我给了他们所有一个名为“contactform”的类。我正在使用 drupal,这意味着我只能使用 CSS。所以我不能将任何其他 HTML 标记添加到输入字段以外的类中。

What i have

What i'm trying to achieve

我唯一可以提供的代码是“Inspect element”中的 HTML 代码,我不能在这里发布,所以我会在下面的评论中发布

我希望你们能帮我解决这个问题,在此先感谢你们!

这就是我能给你的。这是一堆乱七八糟的代码,但我无能为力:

  <form class="webform-client-form webform-client-form-14" action="/drupal/contact-0" method="post" id="webform-client-form-14" accept-charset="UTF-8"><div><div class="form-item webform-component webform-component-textfield webform-component--naam form-group form-item form-item-submitted-naam form-type-textfield form-group"><input required="required" placeholder="Uw naam" class="contactform form-control form-text required" type="text" id="edit-submitted-naam" name="submitted[naam]" value="" size="50" maxlength="40" /> <label class="control-label element-invisible" for="edit-submitted-naam">Naam <span class="form-required" title="This field is required.">*</span></label>
</div><div class="form-item webform-component webform-component-email webform-component--email form-group form-item form-item-submitted-email form-type-webform-email form-group"><input required="required" class="email contactform form-control form-text form-email required" placeholder="Uw emailadres" type="email" id="edit-submitted-email" name="submitted[email]" size="50" /> <label class="control-label element-invisible" for="edit-submitted-email">Email <span class="form-required" title="This field is required.">*</span></label>
</div><div class="form-item webform-component webform-component-textfield webform-component--onderwerp form-group form-item form-item-submitted-onderwerp form-type-textfield form-group"><input required="required" placeholder="Uw onderwerp" class="contactform form-control form-text required" type="text" id="edit-submitted-onderwerp" name="submitted[onderwerp]" value="" size="50" maxlength="255" /> <label class="control-label element-invisible" for="edit-submitted-onderwerp">Onderwerp <span class="form-required" title="This field is required.">*</span></label>
</div><div class="form-item webform-component webform-component-textarea webform-component--bericht form-group form-item form-item-submitted-bericht form-type-textarea form-group"><div class="form-textarea-wrapper"><textarea required="required" placeholder="Uw bericht" class="contactform2 form-control form-textarea required" id="edit-submitted-bericht" name="submitted[bericht]" cols="50" rows="5"></textarea></div> <label class="control-label element-invisible" for="edit-submitted-bericht">Bericht <span class="form-required" title="This field is required.">*</span></label>
</div><input type="hidden" name="details[sid]" />
<input type="hidden" name="details[page_num]" value="1" />
<input type="hidden" name="details[page_count]" value="1" />
<input type="hidden" name="details[finished]" value="0" />
<input type="hidden" name="form_build_id" value="form-4vEZg04Y8Zevfr2GC6ONWVw8UI_4vxf3AL8NRrCFWtg" />
<input type="hidden" name="form_token" value="gNUgTXDR4TC0WhrHOwB7IaYOMOR6Nxz01qjuvrsVPPQ" />
<input type="hidden" name="form_id" value="webform_client_form_14" />
<div class="form-actions"><button class="webform-submit button-primary btn btn-primary form-submit" type="submit" name="op" value="Submit">Submit</button>
</div></div></form>
</section>

CSS

.webform-client-form-14 {
float: left;
width: 45%;
margin-top: 20px;
margin-bottom: 30px;
}

.contactform {
border-radius: 0;
border: none;
}

最佳答案

问题是您将整个表单设置为 45% 宽度,但我们只希望其中的元素为 45% 宽度。如果无法向 html 添加包装器,您将需要使用 :nth-child(n) css 选择器或字段组的自定义类逐个定位每个输入组,例如: .webform-component--bericht.

例子:

.webform-client-form-14 .form-item:nth-child(1) { 
width:45%;
display:block;
float:left;
}

关于html - 用 css 分隔表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41763949/

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