dongluan5740 2012-10-25 22:54
浏览 58
已采纳

水平设置Wordpress小部件

I’m currently working on putting together a child theme off of the new Twenty Twelve Wordpress website. The site has a fluid/liquid structure for its responsiveness (using percentages as opposed to fixed widths in pixels - which would relate to how I may have to style my widgets).

At the top of my template I would like to include a widgetized area where the user/admin can drag and drop items from the available widgets in the list provided.

Ideally, as the design and layout of the site for this section is on a horizontal plane, three widgets would visually look nice in terms of space.

However, if the user would like to add more, I take it that I would need to work with PHP or JavaScript to calculate if there is a certain amount of divs/classes/ids within a section tag for example, change the CSS widths from 33.33% (3 widgets) to 25% (4 widgets) or 50% is there is two etc. ?

How would I be able to accommodate an equally spaced width for each widget and place them next to each other?

  • 写回答

2条回答 默认 最新

  • dsff788655567 2012-10-25 23:07
    关注

    A little messy, but here's a start:

    <?php
    $widgets = wp_get_sidebars_widgets();
    $percentage = !empty($widgets['header-widget-area']) ? floor(100/count($widgets['header-widget-area'])) : 100;
    ?>
    <style type="text/css">
    hgroup .widget{
        width:<?php echo $percentage; ?>% !important;
        float:left;
    }
    </style>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器