【发布时间】:2019-11-22 05:39:40
【问题描述】:
我有一个设计。我在这里遇到了一个问题。
我所做的是,我必须以 100% 的宽度显示前 3 个 li 标签,并保持 33.33% 的 li 标签。
这是我的预期输出
li-100% width
li-100% width
li-100% width
li-33.33% width | li-33.33% width | big image here(not a part of loop)
li-33.33% width | li-33.33% width |
li-33.33% width | li-33.33% width |
但请注意,我正在使用while 循环,所以我会得到类似的输出
li-100% width
li-100% width
li-100% width
li-33.33% width | li-33.33% width | li-33.33% width
li-33.33% width | li-33.33% width | li-33.33% width
li-33.33% width | li-33.33% width | li-33.33% width
我必须每行只显示 2 li。
我正在使用以下逻辑
<div class="wrapperClass">
<ul>
<?php
$index = 0;
$check=0;
while ( condition ) {
if ($index < 3) {?>
<li>
<!--width 100%-->
</li>
<?php }
else{?>
<li>
<!--width with 33.33-->
</li>
<?php } $index++;}?>
</ul>
<img src="">
</div>
css
.wrapperClass ul li:nth-child(1),.wrapperClass ul li:nth-child(2),.wrapperClass ul li:nth-child(3){
width:100%;
}
.wrapperClass ul li{width:33.33%;display: inline-block;}
你能帮我解决这个问题吗?
【问题讨论】:
-
创建li时,可以给不同的class,在合适的class中使用css
-
请提供输出html或小提琴链接
-
@chandershekhar 小提琴链接由于逻辑原因在这里不起作用。我在上图中分享了我的预期输出。
-
@DevsiOdedra,你能分享一个例子吗?
-
@NarenVerma 提供输出 html
标签: php jquery html css html-lists