How to add a border around a canvas?

12,695

Solution 1

outline: black 3px solid;

Outline will draw a line outside the element.

Solution 2

may i suggest this:

<canvas id="canvas"></canvas>
  #canvas{
border:2px solid black !important;}
Share:
12,695
Thomas
Author by

Thomas

just an student wich is making some fun on making batch files

Updated on June 04, 2022

Comments

  • Thomas
    Thomas about 2 years

    I want to now how you can add a border around a canvas. So simply with the CSS code

    border:black 3px solid;
    

    you get the border in the canvas. And I dont want the border in the canvas. I want the border around the canvas. I want this with CSS.

    Thanks for helping!

    my css code:

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