嵌套ul + li元素的问题

时间:2014-10-23 08:13:13

标签: html html-lists

我在下面粘贴了一些代码,这似乎导致了一个问题。据我所知,一切都在适当的地方被打开并打开/关闭,但是Dreamweaver正在强调一些警告。亮点出现在以下项目及其相应的结束标记:

<li class="menu-item"><a href="">Work</a>

代码:

                <nav>
                <ul>
                    <li class="menu-item"><a href="">About</a></li>
                    <li class="menu-item"><a href="">Work</a>
                        <ul class="dropdown">
                            <div class="grid">
                                <div class="unit one-fifth sub-menu-item">
                                    <h3>Filter</h3>
                                    <li><a href="#" data-filter="*">Everything</a></li>
                                    <?php 
                                    $terms = get_terms("category"); // get all categories, but you can use any taxonomy
                                    $count = count($terms); //How many are they?
                                    if ( $count > 0 ){  //If there are more than 0 terms
                                    foreach ( $terms as $term ) {  //for each term:
                                    echo "<li><a href='#' data-filter='.".$term->slug."'>" . $term->name . "</a></li>\n";
                                    //create a list item with the current term slug for sorting, and name for label
                                    }
                                    } 
                                    ?>
                    </li>
                                </div>

                                <div class="unit one-fifth sub-menu-item">
                                    <h3>Recent</h3>
                                </div>

                                <div class="unit two-fifths sub-menu-item">
                                    <h3>Archive</h3>
                                </div>

                                <div class="unit one-fifth sub-menu-item">
                                    <h3>Featured Project</h3>
                                </div>
                            </div>
                        </ul>
                    <li class="menu-item"><a href="">News</a>
                </ul>

            <button class="menu-toggle"><?php _e( 'Primary Menu', 'citizen-films' ); ?></button>
            </nav>

任何帮助都非常感谢!

1 个答案:

答案 0 :(得分:1)

ul标签只能包含li作为子项。 所以,这不是有效的。

 <ul class="dropdown">
                        <div class="grid">

但您可以将div放在li标签中。

看看这个问题: Allowed child elements of ul