【问题标题】:How to divide radio list? Three lists from one in PHP如何划分电台列表? PHP中的三个列表
【发布时间】:2017-03-03 04:23:59
【问题描述】:

我有一个清单:

这是一个代码:

$main_content .= '<div class="InnerTableContainer" >          
                     <table style="width:100%;" >
                     <tr>';
                     if(count($config['site']['newchar_vocations']$world_id]) > 1) {
                        $main_content .= '<td><table class="TableContent" width="100%" >
                                         <tr class="Odd" valign="top">
                                                <td width="160"><br /><b>Select your vocation:</b></td>
                                                <td><table class="TableContent" width="100%" >';
                         foreach($config['site']['newchar_vocations'][$world_id] as $char_vocation_key => $sample_char) {
                             $main_content .= '<tr><td><input type="radio" name="newcharvocation" value="'.$char_vocation_key.'" ';
                             if($newchar_vocation == $char_vocation_key)
                                $main_content .= 'checked="checked" ';
                                $main_content .= '>'.htmlspecialchars($vocation_name[0][$char_vocation_key]).'</td></tr>';
                         }
                        $main_content .= '</table></table></td>';

它会从此配置中将名称添加到列表中:

$config['site']['newchar_vocations'][0] = array(
  1 => 'Goku Sample',
  17 => 'Vegeta Sample',
  32 => 'Piccolo Sample',
  45 => 'C17 Sample',
  57 => 'Gohan Sample',
  71 => 'Trunks Sample',
  83 => 'Cell Sample',
  95 => 'Freeza Sample',
  111 => 'Majin Boo Sample',
  140 => 'C18 Sample',
  206 => 'Dende Sample',
  244 => 'Kuririn Sample',
  256 => 'Pan Sample',
  292 => 'Janemba Sample',
  304 => 'Tenshinhan Sample', 
  280 => 'Videl Sample', 
  316 => 'Jenk Sample', 
  192 => 'Cooler Sample', 
  328 => 'Raditz Sample', 
  340 => 'C16 Sample', 
  352 => 'Turles Sample', 
  364 => 'Bulma Sample', 
  230 => 'Bardock Sample', 
  268 => 'Kaio Sample', 
  178 => 'Chibi Trunks Sample', 
  152 => 'Uub Sample' 
);

如何将此列表划分为例如 3 个部分? 例如每部分 6 个值?像这样:

【问题讨论】:

  • parts 是什么意思?您的意思是每六个项目/值之后列表中的一个中断吗?
  • @justbaron 是的,喜欢这个:i.imgur.com/t6MY5Lt.png
  • 你可以用 css 做到这一点,在 div 上设置一个最大高度,然后浮动单选按钮。
  • @justbaron 你能帮我做吗?我不怎么

标签: php radio-button html-table radiobuttonlist


【解决方案1】:

您可以仅使用 CSS 代码将列表排列为三列。 你可以在这里看到一个例子:

.col {
   -webkit-columns: 3;
   -moz-columns: 3;
   columns: 3;
}
		
p {
   margin: 0;
   background: #F0F0F0;
}
<div class="col">
  <p>A....</p>
  <p>B....</p>
  <p>C....</p>
  <p>D....</p>
  <p>E....</p>
  <p>F....</p>
</div>

这是众多可能性之一

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多