-2

我正在尝试做一个网站。我在菜单栏上遇到问题...在 safari 和 chrome 中它工作正常,但在 Firefox 上我看到菜单项中有一个白色间隙。请检查随附的屏幕截图

这是我的css代码,我正在使用它:

.menu a {
   display:block;
   padding:.7em 2em;
   background:#333;
   color:#ddd;
   text-decoration:none;
   transition:all .3 ease;
}

请帮忙,我尝试了很多,也搜索了一些东西,但无法弄清楚。

4

5 回答 5

0

你为什么不尝试使用浮动:

float:left;
display:block;

在标签中使用它,<li>就像在 mr.itmitica 的示例中一样。这将强制菜单进入一行/块。

于 2014-03-12T03:21:59.390 回答
0

.menu a设置to的边距和边框0

于 2013-08-24T18:32:36.950 回答
0

我猜锚容器是一个列表项(li)元素?如果是这样,您是否从这些元素中删除了边距和填充?

于 2013-08-24T18:35:50.757 回答
0

如果你的菜单是这样的:

<ul>
  <li>...</li>
  <li>...</li>
</ul>

其中 li 是 inline-block,然后这样写:

<ul>
  <li>...</li><li>...</li>
</ul>

内联块元素显示为它们之间有间隙。编写 HTML 元素之间没有间隙会使它消失。

还有几个 CSS 修复,但 HTML“修复”是最可靠的。

于 2013-08-24T19:15:22.637 回答
0

我认为您需要的是一个 CSS 重置器,它可以重置用户代理样式表。

/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}

从中删除不需要的元素,例如abbracronym这段代码是从这里抓取的..

于 2013-08-24T19:08:44.470 回答