我想知道如何在画布周围添加边框。只需使用CSS代码即可实现。
border:black 3px solid;
你在画布中得到了边框,但我不想要画布内的边框。我希望边框围绕着画布。我想用CSS实现这个效果。
感谢你的帮助!
我的CSS代码:
#my_canvas {
max-width: 98%;
max-height: 98%;
height: auto;
width: auto;
margin:auto;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color:white;
border:black 3px solid;
}
#center {
max-width: 66.5%;
max-height: 95%;
height: auto;
width: auto;
margin:auto;
background:;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
Body {
background-color: slategrey;
}
canvas
元素的外部。你有没有偶然设置box-sizing
为border-box
? - James Donnelly