【问题标题】:Unwanted left space with li list menuli 列表菜单中不需要的剩余空间
【发布时间】:2017-04-03 19:51:00
【问题描述】:

一般来说,我坚持为移动版本做正确的菜单。我的问题是左侧列表中不需要的填充(您可以看到填充的左下边框),我很难找到错误。谢谢解答,代码如下:

<nav>
 <div id="menubar">
  <a href="#" id="menu-icon"></a>
  <ul>
   <li><a href="#">Test 1</a></li>
   <li><a href="#">Test 2</a></li>
   <li><a href="#">Test 3</a></li>
   <li><a href="#">Test 4</a></li>
  </ul>
</div>

CSS:

#menu-icon {
    display:inline-block;
    width: 40px;
    height: 40px;
    float: right;
    background: #364886 url(../Images/Interface/menu-icon.png) center;
    }
#menubar {
    position: relative;
    }
ul {
    list-style:none;
    }
ul a:visited,
ul a:link,
ul a:hover  { 
    text-decoration: none;
    color: white;
    }
nav ul, nav:active ul { 
    width: 90%;
    display: none;
    position: absolute;
    background: #364886;
    font-family: 'Roboto', sans-serif;
    font-size: 12pt;
    color: white;
    right: 0px;
    top: 24px;
    }
nav li {
    text-align: center;
    width: 100%;
    padding: 10px 10px 10px 10px; /* top-right-bottom-left*/
    margin: 0;
    border-bottom: 1px dotted white;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    }
nav:hover ul {
    display: block;
    }

【问题讨论】:

  • 请点击编辑器中的&lt;&gt;按钮并创建一个sn-p

标签: html css menu styles html-lists


【解决方案1】:

在 ul 中添加 padding:0 ul { 列表样式:无; 填充:0; }

【讨论】:

  • 它很棒而且很有效,我想我什么都试过了。非常感谢。一般问题都解决了。
  • 欢迎朋友 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-12
  • 2023-03-29
  • 1970-01-01
  • 1970-01-01
  • 2018-10-09
相关资源
最近更新 更多