可以很好地调整大小

可以很好地调整大小

本文介绍了水平菜单,可以很好地调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用以下水平菜单时遇到了困难:

I'm struggling with the following horizontal menu:

http://jsfiddle.net/UeFeb/

我希望菜单中的每个

  • 项目用反斜杠分隔.我的菜单基于这种方法:https://stackoverflow.com/a/6880421/556006

    I'd like each <li> item in the menu to be separated by a backslash. I've based my menu on this method: https://stackoverflow.com/a/6880421/556006

    如何获取菜单:

    • 让斜杠位于每个
    • 元素之间的负空间中,以便它们始终位于每个后续
    • 之间
    • 当浏览器宽度低于 730px 时,自动调整为 2 行,每行 3 个
    • 浏览器宽度减少的时间)
    • Have the slashes sit in the negative space between each <li> element so that they always sit in between each subsequent <li>
    • When the browser width drops below 730px, automatically resize to 2 rows of 3 <li> items (at the moment it drops one <li> down at a time as the browser width is reduced)

    想法?

    推荐答案

    您可以像这样使用 CSS 自动添加斜杠:

    You can add the slashes automatically with CSS like so:

    #menu li:after {
        content: "020 02F";
    }
    

    至于调整大小,您可以使用 @media 查询来伪造它.看看这个演示(根据需要重新调整):

    And as for the resizing you can sorta fake it using @media queries for that. Take a look at this demo (readjust as necessary):

    http://jsfiddle.net/andresilich/UeFeb/1/

    将我的答案改造成更令人满意的答案,以下是未来用户的细分:

    Reworked my answer into a more satisfactory one, here is the breakdown for future users:

    HTML

    <ul id="menu" style="list-style:none">
         <li><a href="#asics">ASICS</a></li>
         <li>/</li>
         <li><a href="#plants">PLANTS PLUS</a></li>
         <li>/</li>
         <li><a href="#tooheys">TOOHEYS</a></li>
         <li>/</li>
         <li><a href="#olympics">OLYMPICS</a></li>
         <li>/</li>
         <li><a href="#panadol">PANADOL</a></li>
         <li>/</li>
         <li><a href="#kia">KIA CADENZA</a></li>
    </ul>
    

    CSS

    #menu {
        height: 125px;
        margin: 0 auto;
        text-align: justify;
        -ms-text-justify: distribute-all-lines;
        text-justify: distribute-all-lines;
    
        /* just for demo */
        min-width: 90%;
    }
    
    #menu li {
        max-width: 150px;
        vertical-align: top;
        display: inline-block;
        *display: inline;
        zoom: 1
    }
    
    #menu:after {
        content: '';
        width: 100%;
        display: inline-block;
        font-size: 0;
        line-height: 0
    }
    
    @media screen and (max-width:730px) {
        #menu {
            min-width: 1px;
            width: 35%;
        }
    }
    

    http://jsfiddle.net/andresilich/UeFeb/3/

    这篇关于水平菜单,可以很好地调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 08-31 04:06