为什么不是';t图像是否放置在html页面的左上角?
我得到了一个额外的超简单html页面,其中只有一个图像作为唯一的内容:为什么不是';t图像是否放置在html页面的左上角?,html,css,image,Html,Css,Image,我得到了一个额外的超简单html页面,其中只有一个图像作为唯一的内容: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Anzeige<
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Anzeige</title>
</head>
<body>
<img alt="Anzeige" src="images/image.gif" />
</body>
</html>
显示
在Safari和Firefox(以及UIWebView,这是我最初的问题)中,图像不显示在左上角,而是有一个大约5像素的白色边缘。当我将图像单独加载到Firefox中时,情况是一样的,但在Safari和UIWebView中,图像的左上角没有边框
有什么想法吗 您需要使用以下命令将浏览器默认填充和边距重置为0: 它的工作原理是所有浏览器都实现了默认的边距和边距,将其添加到CSS文件中会将所有浏览器的边距和边距重置为0px 此代码将涵盖您将拥有的所有浏览器默认程序:
/* 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;
}
您需要使用以下命令将浏览器默认填充和边距重置为0: 它的工作原理是所有浏览器都实现了默认的边距和边距,将其添加到CSS文件中会将所有浏览器的边距和边距重置为0px 此代码将涵盖您将拥有的所有浏览器默认程序:
/* 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;
}
听起来你在谈论默认页边距。添加以下CSS:
html, body { margin: 0; padding: 0; border: 0 }
听起来你在谈论默认页边距。添加以下CSS:
html, body { margin: 0; padding: 0; border: 0 }
确切地使用
*
将body和*margins/paddings设置为零(0)@Tobiask不鼓励使用它,因为它是浏览器密集型的,因此Eric Mayer是一种更有效的做事方式。没错!使用*
将body和*margins/paddings设置为零(0)@Tobiask不鼓励使用,因为它是浏览器密集型的,因此Eric Mayer是一种更有效的方法。