dongyin4202 2013-08-06 04:38
浏览 29

复选框和PHP和CSS

Ok let me rephrase this a bit. I have a form in the form I have checkboxes they currently display vertically I need them to display horizontally. The form is wrapped in a section tag. I put the id tag of colorSwatches as , I've tried , I've tried and for colorSwatches in the CSS I put display:inline-block. It did not work any variation. Here is the URL to see the page in question http://www.inertiastreak.com/serial_quilters/order.php

I have the following block of code:

<ul id="colorSwatches">
          <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['color[]'] == 'color[]') ? 'checked="checked"' : ''; ?>
              <li><input type="checkbox" name="color[]" value="red" />Red</li>
              <li><input type="checkbox" name="color[]" value="orange" />Orange</li>
              <li><input type="checkbox" name="color[]" value="yellow" />Yellow</li>
              <li><input type="checkbox" name="color[]" value="green" />Green</li>
              <li><input type="checkbox" name="color[]" value="blue" />Blue</li> 
              <li><input type="checkbox" name="color[]" value="purple" />Purple</li> 
              <li><input type="checkbox" name="color[]" value="pink" />Pink</li>
              <li><input type="checkbox" name="color[]" value="brown" />Brown</li> 
              <li><input type="checkbox" name="color[]" value="black" />Black</li>                   
              <li><input type="checkbox" name="color[]" value="white" />White</li>                   
          </ul>

Right now the list of checkboxes show in a vertical line. I would like the checkbox and color to show up in a horizontal line. Every which variation of CSS I put in is not working at all. I have tried putting the id of colorSwatches as section#colorSwatches ul li {display:inline-block;} and it didn't work. The only way it worked was that I closed the form above the list of colors, then closed the section tag. Opened a new section tag and a new form tag and essentially created a second form, which was unneeded.

If someone could please advise how to go get a stack of input fields like the ones above to display in the inline-block fashion that would be great. UL and LI can be removed it doesn't matter to me.

Btw the PHP shouldn't be changed.

  • 写回答

4条回答 默认 最新

  • duanmao9918 2013-08-06 04:42
    关注

    Give class to li as class="li_color".

    <ul id="colorSwatches">
                  <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['color[]'] == 'color[]') ? 'checked="checked"' : ''; ?>
                  <li class="li_color"><input type="checkbox" name="color[]" value="red" />Red</li>
                  <li class="li_color"><input type="checkbox" name="color[]" value="orange" />Orange</li>
                  <li class="li_color"><input type="checkbox" name="color[]" value="yellow" />Yellow</li>
                  <li class="li_color"><input type="checkbox" name="color[]" value="green" />Green</li>
                  <li class="li_color"><input type="checkbox" name="color[]" value="blue" />Blue</li> 
                  <li class="li_color"><input type="checkbox" name="color[]" value="purple" />Purple</li> 
                  <li class="li_color"><input type="checkbox" name="color[]" value="pink" />Pink</li>
                  <li class="li_color"><input type="checkbox" name="color[]" value="brown" />Brown</li> 
                  <li class="li_color"><input type="checkbox" name="color[]" value="black" />Black</li>                   
                  <li class="li_color"><input type="checkbox" name="color[]" value="white" />White</li>                   
              </ul>
    

    Give the style to li_color as

    #colorSwatches {width:100%;}
    #colorSwatches .li_color { float:left; width:100px; }
    

    If width is not enough, you can increase.

    评论

报告相同问题?

悬赏问题

  • ¥20 关于多单片机模块化的一些问题
  • ¥30 seata使用出现报错,其他服务找不到seata
  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取
  • ¥15 vue3+element-plus页面崩溃
  • ¥15 像这种代码要怎么跑起来?
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection