douxu2081 2015-02-18 13:58
浏览 38
已采纳

PHP / CodeIgniter:将元素放在同一行?

I am using code igniter in order to generate elements. I want to have a form label and an input box on the same line.

However currently the input box is displayed below the label.

How can I ensure that the input box is on the same line as the label, and to its right.

<?php

echo form_label('Age: ','age');

echo form_input('userAge',"");

?>
  • 写回答

1条回答 默认 最新

  • duanfu5239 2015-02-18 14:27
    关注

    Probably something like this:

    echo form_label('Age: '.form_input('userAge',""),'age');
    

    Based on your comments, this is how you force additional spaces:

    echo form_label('Age:&nbsp;&nbsp;&nbsp;'.form_input('userAge',""),'age');
    

    Based on your other comment:

    echo form_label('Age:&nbsp;&nbsp;&nbsp;'.form_input(array('name'=>'userAge','value'=>'johndoe','readonly'=>'readonly')),'age');
    

    For more information you should read through:

    http://www.codeigniter.com/user_guide/helpers/form_helper.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥15 对于这个问题的解释说明
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备