【发布时间】:2021-03-06 09:32:43
【问题描述】:
我正在尝试将表单中的输入字段放置在 3 列中,现在的问题是我无法弄清楚如何去做,因为我的代码比我最初计划的要多。
无论我尝试过什么,它都没有奏效,已经坐了几个小时,但我不知道该怎么办。任何帮助将不胜感激,在此先感谢。
.form-control {
position: relative;
padding-bottom: 20px;
}
.input-fields {
display: flex;
flex-direction: column;
margin-right: 4%;
width: 100%;
}
.input-fields .input,
.kompetanse textarea {
margin: 10px 0;
background: transparent;
border: 0;
font-family: inherit;
border-bottom: 2px solid #fff;
padding: 10px;
color: #fff;
font-size: 20px;
}
.input-fields .input {
width: 32%;
float: left;
}
.kompetanse textarea {
height: 150px;
width: 100%;
}
<div class="cv-form">
<form name="cv" id="cv" autocomplete="off" class="input-fields">
<h1 class="h1-venstre">Curriculum Vitae</h1>
<div class="form-control">
<input id="navn" type="text" class="input" placeholder="Navn" value=''><small>Feilmelding</small>
</div>
<div class="form-control">
<input id="adresse" type="text" class="input" placeholder="Adresse" value=''><small>Feilmelding</small>
</div>
<div class="form-control">
<input id="epost" type="text" class="input" placeholder="E-post" value=''><small>Feilmelding</small>
</div>
<div class="form-control">
<input id="mobil" type="text" class="input" placeholder="Mobil" value=''><small>Feilmelding</small>
</div>
<div class="form-control">
<input id="status" type="text" class="input" placeholder="Sivil status" value=''><small>Feilmelding</small>
</div>
<div class="form-control"><input id="født" type="text" class="input" placeholder="Fødselsdato" value=''><small>Feilmelding</small></div>
<div class="form-control">
<input id="utdanning" type="text" class="input" placeholder="Utdanning" value=''></div>
<div class="form-control"><input id="yrkeserfaring" type="text" class="input" placeholder="Yrkeserfaring" value=''>
<small>Feilmelding</small>
</div>
<div class="form-control">
<input id="kurs" type="text" class="input" placeholder="Kurs/etterutdannelse" value=''><small>Feilmelding</small>
</div>
<div class="form-control">
<input id="annet" type="text" class="input" placeholder="Andre opplysninger" value=''><small>Feilmelding</small>
</div>
<div class="kompetanse">
<textarea id="kompetanse" placeholder="Kompetanse" value=''></textarea>
</div>
<button type="submit" onclick="printetekst();" id="openBtn" class="custom">Send inn cv</button>
</form>
【问题讨论】:
-
也许使用css网格? w3schools.com/css/css_grid.asp
-
@Kielstra 我可以尝试,但从我读到的人们通常认为使用 flexbox,唯一的问题是我无法弄清楚如何实现它。
-
Flexbox 也是一种选择,是的。如果我是你,我会查找教程。我发现这个来源也非常有用:css-tricks.com/snippets/css/a-guide-to-flexbox。我知道必须重写相当大的一段 html 可能会令人生畏,但有时就是这样。你不能指望这里的任何人都会为你做所有的工作。
-
还有很多看起来很傻的 CSS“游戏”,但它们是掌握 flexbox 和网格等概念的一种非常简单的方法,例如:flexboxfroggy.com
-
@Kielstra 感谢您的提示,我会看看教程。