【问题标题】:Aligning two input fields side by side并排对齐两个输入字段
【发布时间】:2018-02-16 19:19:16
【问题描述】:

我知道这是一个非常愚蠢的问题,但我已经尝试了所有方法(div 包装器、浮动 div、p 类)并且无法弄清楚。我只是想并排对齐第二列上的“isim & soyisim”字段(这些是姓名和姓氏字段)。我的代码有问题,但我找不到它,这让我发疯。任何帮助将不胜感激。看这里:

http://www.wondercatspopup.com/hesabim/

代码如下:

     <p class="form-row form-row-first">
          <label style="display:none!important;" for="reg_billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?>
            <span class="required">
             *
            </span>
          </label>

          <input type="text" class="woocommerce-Input woocommerce-Input--text input-text placeholder" placeholder="İsim *" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />
    
         <label style="display:none!important;" for="reg_billing_last_name"><?php _e( 'Last name', 'woocommerce' ); ?><span class="required">*</span></label>
         <input type="text" class="woocommerce-Input woocommerce-Input--text input-text placeholder" placeholder="Soyisim *" name="billing_last_name" id="reg_billing_last_name" value="<?php if ( ! empty( $_POST['billing_last_name'] ) ) esc_attr_e( $_POST['billing_last_name'] ); ?>" />
       
      </p>

      <p class="form-row form-row-wide">

          <label style="display:none!important;" for="reg_billing_phone"><?php _e( 'Phone', 'woocommerce' ); ?></label>
          <input type="text" class="woocommerce-Input woocommerce-Input--text input-text placeholder" placeholder="Telefon *" name="billing_phone" id="reg_billing_phone" value="<?php esc_attr_e( $_POST['billing_phone'] ); ?>" />
      </p>

       <div class="clear"></div>

【问题讨论】:

  • 将您的代码添加到问题中。这意味着,如果有人在您的网站消失 5 年后发现此问题,他们仍然可以看到该问题。
  • 刚刚添加。感谢您的反馈。

标签: php html css class


【解决方案1】:

您需要为input box 添加宽度。那我就好好干吧```

input[type="text"] { //or your class 
width: 30%;
display: inline-block;
margin-right:20px; // to set some margin in the right
}

【讨论】:

    【解决方案2】:

    您的文本框正在使用全屏。

    尝试使用 display: inline-block 属性为您的文本框设置特定宽度。

    示例: HTML

    <div>
    <input type="text" name="firstname" />
    <input type="text" name="lastname" />
    </div>
    

    风格

    input[type="text"] {
        width: 150px;
        display: inline-block;
    }
    

    【讨论】:

    • 另一种方法:你也可以使用“display : flex”样式来div box
    • 很高兴它成功了。那你能不能接受我的回答。
    • 您好,它在台式机上运行良好,但在移动设备上,当放置在页脚时会奇怪地对齐。 (请看上面的链接)你能帮我做一个吗?
    • 对于移动设备,每个设备都有不同的屏幕尺寸,因此如果您设置硬编码值(即 150 像素),它将无法正确对齐。要么根据屏幕宽度使用@media 查询到特定的宽度/高度,要么使用流畅的设计(即宽度百分比:30%)
    猜你喜欢
    • 1970-01-01
    • 2020-07-18
    • 2016-12-12
    • 2014-06-28
    • 2023-03-06
    • 1970-01-01
    • 2017-04-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多