css - 如何在 Canvas 周围添加边框?

标签 css canvas border

现在我想了解如何在 Canvas 周围添加边框。如此简单地使用 CSS 代码

border:black 3px solid;

您在 Canvas 中 得到边框。而且我不想要 Canvas 中的边框。我想要 Canvas 周围的边框。我想要这个与 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;
}

最佳答案

outline: black 3px solid;

Outline 会在元素外画一条线。

关于css - 如何在 Canvas 周围添加边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27381725/

相关文章:

java - 尝试在 SurfaceView 的 Canvas 上制作动画

javascript - 如何将 CSS 翻译添加到现有翻译中?

html - 是否可以在 HTML5/CSS 中使图像的某些部分透明

html - iOS 浏览器 : unwanted scroll when keyboard is opened and body scroll is disabled

jquery - 将 border 属性设置为 li - html 中的标记会将最后一个 li 元素降到下一行

CSS 样式未到达边缘

html - Chrome 1px不可避免的td之间的间距

javascript - 为什么我在 jquery 中的 if 语句不能检测图像大小?

javascript - 如何在 Fabric.js 中将 Canvas 导出为 HTML?

javascript - 自动放置流程图形状的算法