1

我的小提琴:

http://jsfiddle.net/kpdgQ/16/

为什么橙色画布下面有一个带有一点空间的垂直滚动条?

<div>
    <canvas></canvas>
</div>

div {   
    height:100%;
    width:100%;   
    background:blue;
}
canvas {
    background-color: orange;
    width:100%;
    height:100%;
}
html,body{
    height:100%;
    width:100%;
}

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;
}

body {
    line-height: 1;
}
4

3 回答 3

2

Canvas 默认具有 display:inline .. 当您将其更改为 display:block 时,它应该显示正常.. (所有图像都是相同的情况..)

于 2013-09-24T10:15:33.940 回答
0

正如@Mag 所说,您可以添加 display:block 或设置 float 属性。您还可以将 overflow:hidden 添加到包含画布标签的 div 中。

于 2013-09-24T10:19:56.757 回答
0

css 更改为:

canvas {
    background-color: orange;
    width:100%;
    height:100%;
    display:block;}

http://jsfiddle.net/kpdgQ/18/

于 2013-09-24T10:20:26.237 回答