Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何扩展我的CSS3菜单并减小其宽度_Html_Css_Menu - Fatal编程技术网

Html 如何扩展我的CSS3菜单并减小其宽度

Html 如何扩展我的CSS3菜单并减小其宽度,html,css,menu,Html,Css,Menu,我当时正在做一个web项目,然后有一个要求我应该在我的网站上添加一个顶级菜单。所以我搜索了一下,从这个URL中找到了一个菜单。 但是,当我添加所需的css文件和字体时,菜单显示在布局外,如下所示:- 那么,有谁能建议我如何做到以下几点:- 水平扩展菜单以覆盖整个屏幕。至于顶部蓝色区域 让它正好位于蓝色顶部区域下方 缩小菜单宽度,使其与面包屑相同 谢谢 菜单的css是:- .clearfix { clear: both; } .wrap { width: 940px;

我当时正在做一个web项目,然后有一个要求我应该在我的网站上添加一个顶级菜单。所以我搜索了一下,从这个URL中找到了一个菜单。 但是,当我添加所需的css文件和字体时,菜单显示在布局外,如下所示:-

那么,有谁能建议我如何做到以下几点:-

  • 水平扩展菜单以覆盖整个屏幕。至于顶部蓝色区域
  • 让它正好位于蓝色顶部区域下方
  • 缩小菜单宽度,使其与面包屑相同
  • 谢谢

    菜单的css是:-

    .clearfix {
        clear: both;
    }
    
    .wrap {
        width: 940px;
        margin: 4em auto;
    }
    
    nav {
        background: -webkit-gradient(linear, center top, center bottom, from(#fff), to(#ccc));
        background-image: linear-gradient(#fff, #ccc);
        border-radius: 6px;
        box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.4);
        padding: 0 10px;
        position: relative;
    }
    
    .menu li {
        float: left;
        position: relative;
    }
    
    .menu li a {
        color: #444;
        display: block;
        font-size: 14px;
        line-height: 20px;
        padding: 6px 12px;
        margin: 8px 8px;
        vertical-align: middle;
        text-decoration: none;
    }
    
    .menu li a:hover {
        background: -webkit-gradient(linear, center top, center bottom, from(#ededed), to(#fff));
        background-image: linear-gradient(#ededed, #fff);
        border-radius: 12px;
        box-shadow: inset 0px 0px 1px 1px rgba(0,0,0,0.1);
        color: #222;
    }
    
    /* Dropdown styles */
    
    .menu ul {
        position: absolute;
        left: -9999px;
        list-style: none;
        opacity: 0;
        transition: opacity 1s ease;
    }
    
    .menu ul li {
        float: none;
    }
    
    .menu ul a {
        white-space: nowrap;
    }
    
    /* Displays the dropdown on hover and moves back into position */
    .menu li:hover ul {
        background: rgba(255,255,255,0.7);
        border-radius: 0 0 6px 6px;
        box-shadow: inset 0px 2px 4px rgba(0,0,0,0.4);
        left: 5px;
        opacity: 1;
    }
    
    /* Persistant Hover State */
    .menu li:hover a {
        background: -webkit-gradient(linear, center top, center bottom, from(#ccc), to(#ededed));
        background-image: linear-gradient(#ccc, #ededed);
        border-radius: 12px;
        box-shadow: inset 0px 0px 1px 1px rgba(0,0,0,0.1);
        color: #222;
    }
    
    .menu li:hover ul a {
        background: none;
        border-radius: 0;
        box-shadow: none;
    }
    
    .menu li:hover ul li a:hover {
        background: -webkit-gradient(linear, center top, center bottom, from(#eee), to(#fff));
        background-image: linear-gradient(#ededed, #fff);
        border-radius: 12px;
        box-shadow: inset 0px 0px 4px 2px rgba(0,0,0,0.3);
    }
    
    @font-face {
      font-family: 'IconicStroke';
        src: url("~/fonts/iconic/iconic_stroke.eot");
        src: local('IconicStroke'),
           url("~/fonts/iconic/iconic_stroke.svg#iconic") format('svg'),
           url("~/fonts/iconic/iconic_stroke.otf") format('opentype');
    }
    
    .iconic {
        color:inherit;
        font-family: "IconicStroke";
        font-size: 38px;
        line-height: 20px;
        vertical-align: middle;
    }
    
    a.iconic:hover {
        color:inherit;
    }
    
    我的建议!使用firebug(firefox的插件)。单击菜单,它将打开所有css。尝试动态更改它们,并立即更改。它甚至提供了需要进行更改的文件

    除此之外,约翰说的是对的。使用流体布局(%)优于刚性布局(px)。所以,当你们说你们需要一个和页面大小相同的菜单时,那个么就让它100%


    快乐编码

    将.wrap类更改为使用百分比宽度而不是固定像素宽度,假设wrap是菜单的外部元素,则需要查看菜单的html才能确定。要使其直接位于顶部栏下方,请去掉边距或至少减少边距。url引用中的“tilde”(src:url(“~/fonts/…)是什么意思?@PatrickEvans。感谢patrick的回复,我将.wrap类更改为.wrap{width:100%;}。不知何故,菜单看起来好多了。但我面临的唯一问题是,在每个菜单旁边都有一个*标记。因为菜单使用无序列表来构建其元素。那么有没有办法删除无序列表标记?向我们展示您的html或JSFIDLE(JSFIDLE.net),以便我们可以查看代码