隐藏<li>项目类

时间:2017-12-03 18:16:56

标签: css hide

我想隐藏这一点:$sql = "select ID from profile_table where status = 'Active' AND (ID in (select ID from activity_table where date_time < DATE_SUB(NOW(),INTERVAL 30 MINUTE)) or ID NOT IN (select ID from activity_table))" ,如下面的代码所示(另请参阅此处https://poiimata.com/poets/):

<li class="categories">Kατηγορίες<ul>

我尝试使用

<li class="categories">Kατηγορίες<ul>   
<li class="cat-item cat-item-123">
    <a href="https://poiimata.com/category/robert-frost/" >Robert Frost</a>
</li>
<li class="cat-item cat-item-124">
    <a href="https://poiimata.com/categoryshlain-goldberg/" >Shlain</a>
</li>

但结果是隐藏了那一个下面的所有项目(整个列表)。

3 个答案:

答案 0 :(得分:3)

这是因为您的HTML代码无效:

<li class="categories">Kατηγορίες<ul>
_________________________________^^^^

浏览器会将您的代码评估为以下格式,这就是为什么所有的li都被隐藏起来了:

<ul>
    <li class="categories">Kατηγορίες
       <ul>
          <li class="cat-item cat-item-123"><a href="https://poiimata.com/category/robert-frost/">Robert Frost</a>
          </li>
          <li class="cat-item cat-item-124"><a href="https://poiimata.com/categoryshlain-goldberg/">Shlain</a>
          </li>
       </ul>
    </li>
</ul>

相反它应该是:

<ul>
  <li class="categories">Kατηγορίες</li>
  <li class="cat-item cat-item-123"><a href="https://poiimata.com/category/robert-frost/">Robert Frost</a>
  </li>
  <li class="cat-item cat-item-124"><a href="https://poiimata.com/categoryshlain-goldberg/">Shlain</a>
  </li>
</ul>

段:

.categories {
  display: none;
}
<ul>
  <li class="categories">Kατηγορίες</li>
  <li class="cat-item cat-item-123"><a href="https://poiimata.com/category/robert-frost/">Robert Frost</a>
  </li>
  <li class="cat-item cat-item-124"><a href="https://poiimata.com/categoryshlain-goldberg/">Shlain</a>
  </li>
</ul>

答案 1 :(得分:0)

您的HTML中似乎只有一个错误。您使用不正确的结束标记,因此隐藏整个事物。

import java.util.Arrays;
import java.util.Scanner;

public final class PointsAndSegmentsSolution {

    enum PointType { // in order of sort, so that the point will be counted on both segment start and end coordinates
        SEGMENT_START,
        POINT,
        SEGMENT_END,
    }

    static class SuperPoint {
        final PointType type;
        final int x;
        final int index; // -1 (actually does not matter) for segments, index for points

        public SuperPoint(final PointType type, final int x) {
            this(type, x, -1);
        }

        public SuperPoint(final PointType type, final int x, final int index) {
            this.type = type;
            this.x = x;
            this.index = index;
        }
    }

    private static int[] countSegments(final SuperPoint[] allPoints, final int pointsCount) {
        Arrays.sort(allPoints, (o1, o2) -> {
            if (o1.x < o2.x)
                return -1;

            if (o1.x > o2.x)
                return 1;

            return Integer.compare( o1.type.ordinal(), o2.type.ordinal() ); // points with the same X coordinate by order in PointType enum
        });

        final int[] result = new int[pointsCount];
        int counter = 0;

        for (final SuperPoint superPoint : allPoints) {
            switch (superPoint.type) {

                case SEGMENT_START:
                    counter++;
                    break;

                case SEGMENT_END:
                    counter--;
                    break;

                case POINT:
                    result[superPoint.index] = counter;
                    break;

                default:
                    throw new IllegalArgumentException( String.format("Unknown SuperPoint type: %s", superPoint.type) );
            }
        }

        return result;
    }

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int segmentsCount = scanner.nextInt();
        final int pointsCount = scanner.nextInt();

        final SuperPoint[] allPoints = new SuperPoint[(segmentsCount * 2) + pointsCount];
        int allPointsIndex = 0;

        for (int i = 0; i < segmentsCount; i++) {
            final int start = scanner.nextInt();
            final int end = scanner.nextInt();

            allPoints[allPointsIndex] = new SuperPoint(PointType.SEGMENT_START, start);
            allPointsIndex++;

            allPoints[allPointsIndex] = new SuperPoint(PointType.SEGMENT_END, end);
            allPointsIndex++;
        }

        for (int i = 0; i < pointsCount; i++) {
            final int x = scanner.nextInt();

            allPoints[allPointsIndex] = new SuperPoint(PointType.POINT, x, i);
            allPointsIndex++;
        }

        final int[] pointsSegmentsCounts = countSegments(allPoints, pointsCount);

        for (final int count : pointsSegmentsCounts) {
            System.out.print(count + " ");
        }
    }
}

尝试改为:

 <li class="categories">Kατηγορίες<ul>  <!--- closed <li> with <ul> --->
<li class="cat-item cat-item-123">
    <a href="https://poiimata.com/category/robert-frost/" >Robert Frost</a>
</li>
<li class="cat-item cat-item-124">
    <a href="https://poiimata.com/categoryshlain-goldberg/" >Shlain</a>
</li>

并将CSS更改为

<ul class="categories">
<li >Kατηγορίες<li> 
   <li class="cat-item cat-item-123">
    <a href="https://poiimata.com/category/robert-frost/" >Robert Frost</a>
   </li>
   <li class="cat-item cat-item-124">
    <a href="https://poiimata.com/categoryshlain-goldberg/" >Shlain</a>
   </li>

</ul>

这只是完成它的一种方式。你可以采取不同的角度。

答案 2 :(得分:-1)

由于li包含您不需要隐藏的标记,因此您需要屏蔽隐藏文本。例如:

&#13;
&#13;
.categories {
  font-size: .1%;
}

.categories ul {
  font-size: 100000%;
}
&#13;
&#13;
&#13;

如果只有子元素不是错误...