문제

I've been assigned to design a nav menu using CSS.
I've designed it accordingly, but I didn't find help regarding how to revert the menu back to its unordered list view when the browser window becomes too small to fit the menu.
I can't use scripting, only pure CSS.
Any suggestions?


The HTML code is as following:

        <nav class="line">
            <ul>
                <li><a href="#">Home</a></li>
                <li><a href="#">Articles</a>
                    <ul>
                        <li><a href="#">Things</a></li>
                        <li><a href="#">Stuff</a></li>
                        <li><a href="#">Subjects</a>
                            <ul>
                                <li><a href="#">Serious subjects</a></li>
                                <li><a href="#">Frivolous subjects</a></li>
                            </ul>
                        </li>
                    </ul>
                </li>
                <li><a href="#">Solving homework</a>
                    <ul>
                        <li><a href="#">Not here</a></li>
                        <li><a href="#">Not here either</a></li>
                    </ul>
                </li>
                <li><a href="#">Inspiration</a></li>
            </ul>
        </nav>
도움이 되었습니까?

해결책

What you are trying to do is a responsive page. That is also called the 'mobile first grid system' because you make it fit the small screen first, then you only add new elements to the classes in media queries as you move to bigger screens.

This should get you started: http://css-tricks.com/resolution-specific-stylesheets/ http://css-tricks.com/css-media-queries/

And just google around the subject of 'media queries' and 'responsive web page' and you should find all the info you need.

Good luck!

다른 팁

Try to use media queries.
For example:
@media (max-width:400px) { ul li ul { display:none; } }

You can use media queries for this.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top