以下是相关网页的链接:http://www.canning.co.nz/
在IE中,无序列表显示每行之间的空白最小。但是,在Firefox中,还有更多的空白区域。
如何修复此网页,以便无论浏览器查看此页面,无序列表都会显示在IE中。
我是否需要添加某个doctype或使用CSS?
答案 0 :(得分:2)
明确删除这些<p>
代码中的边距,使其在所有浏览器中都具有相似的外观。
p {
margin: 0;
}
原因是,如果没有提供其他浏览器,浏览器会使用他们使用的标准样式表。这些样式表在不同的浏览器之间有所不同,因此您必须明确设置一些值或使用CSS重置样式(例如this one by David Walsh)。
答案 1 :(得分:1)
使用重置CSS **
Reset.CSS只是CSS样式的集合,用于删除和中和HTML元素的不一致默认样式。
它只是清除Web浏览器的默认值,您不需要再次为每个元素更改这些差异。
//Reset CSS - include this stylesheet in your html page before your main css file
/* 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;
}
答案 2 :(得分:0)
您的<p>
代码为每个<li>
代码提供了保证金,请使用
ul li p {
margin: 0px;
}
它应该摆脱空白。 (或者只是使用p { margin: 0px }
,如果您要将其从所有<p>
代码中删除,而不管它们是否在列表中?