注: wordpress 環境の Salient テーマからコードを抽出しようとしてきたため、問題を最も単純な形式で再現することはまだできていません。この質問がコミュニティにとって有益なものになることを願っています。
これまでのところ、私の問題は以下のとおりです。
コンテンツが画面に表示される方法をより適切に制御しようとしていますが、CSS について理解していないようです。要素の合計幅の計算にパディングとボーダーを含む「box-sizing: border box」プロパティを使用してみました。入力要素とスパン要素の状態を表示するリンクを追加しました
「Chrome Devtool」Span要素コンテンツエリア
問題はマージン関連の問題であるため、ボックスのサイズ変更は機能しないと思います。私の推測では、「margin-left」プロパティがコンテンツ領域全体に影響を与え、コンテンツを span 要素の外に押し出しているということです。ただし、入力要素をスパン要素内に含める必要があります
Lucien Dubois のおかげで HTML と CSS を追加
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box; }
.contact-fields input, textarea{
margin-left: 12px;
}
.wpcf7-form-control-wrap {
display: block !important;
position: relative;
}
div, span, h5, p {
vertical-align: baseline;
font-family: inherit;
font-weight: inherit;
font-style: inherit;
font-size: 100%;
outline: 0;
padding: 0;
margin-right: 0;
border: 0
}
h5
{
font-family:Raleway;
line-height:16px;
margin-bottom: 7px;
color:#444;
letter-spacing:0px;
font-weight:600;
}
.form-label {
clear: both;
font-size: 20px
}
h5 {
vertical-align: baseline;
font-style: inherit;
outline: 0;
padding: 0;
margin-top: 0;
margin-right: 0;
margin-left: 0;
border:0
}
.first-name, .last-name {
display: inline-block;
width: 40%;
margin-right: 9px;
}
.first-name input, .last-name input {
width: 62%;
}
input {
margin-bottom: 20px;
margin-top: 5px;
}
<div class="contact-fields">
<div class="name-section">
<div class="first-name">
<h5 class="form-label"> First Name:</h5>
<p>
<span class="wpcf7-form-control-wrap fname">
<input type="text"
name="fname"
value=""
size="40"
maxlength="50"
class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required input-field"
aria-required="true"
aria-invalid="false">
</span>
</p>
</div>
<div class="last-name">
<h5 class="form-label"> Surname:</h5>
<p>
<span class="wpcf7-form-control-wrap lname">
<input type="text"
name="lname"
value=""
size="40"
maxlength="50"
class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required input-field"
aria-required="true"
aria-invalid="false"></span>
</p>
</div>
</div>
</div>