+ 7

CSS Borders out of the body

Hi, I tried to add simple borders arround my canvas, at the upper left corner it's work but at the lower right ... border brim over :( ############################################## This is my javascript : //VARIABLES var WIDTH = 500; var HEIGHT = 500; var FPS = 60; //CANVAS INIT c = document.createElement('canvas'); document.body.appendChild(c); ctx = c.getContext('2d'); WIDTH = window.innerWidth; HEIGHT = window.innerHeight; c.setAttribute('width', WIDTH); c.setAttribute('height', HEIGHT); c.setAttribute('id', 'canvas'); //FUNCTIONS function clear(){ ctx.fillStyle = '#333'; ctx.fillRect(0, 0, WIDTH, HEIGHT); } function update(){ clear(); } setInterval(update, 1000/FPS); ########################################### And this is my css : body{ margin: 0px; padding: 20px; overflow: hidden; background-color: #333; } #canvas{ border : dashed white; }

18th Oct 2017, 12:33 PM
S e r e y n
42 Answers
+ 5
not #canvas {} but canvas { border-left: 1px solid black; (choose what you want) border-top: ..... } or border: 2px outset #CCC; for example
18th Oct 2017, 1:32 PM
NoxFly
NoxFly - avatar
+ 6
np everybody need to learn :D even if you know a lot
18th Oct 2017, 5:28 PM
NoxFly
NoxFly - avatar
+ 6
#name { } will apply to the element with an ID set to "name" .name { } will apply to all the element with a class set to "name" name { } will apply to all the name elements ;) Also, as Dorian said you have to set a border since the default one is 0. It's kinda funny how we all 3 are French but had this conversation in English :)
18th Oct 2017, 7:48 PM
Dapper Mink
Dapper Mink - avatar
+ 6
Omelette du fromage
18th Oct 2017, 8:09 PM
Dapper Mink
Dapper Mink - avatar
+ 5
thanks I have to learn (again) CSS I think šŸ˜…
18th Oct 2017, 5:24 PM
S e r e y n
+ 5
mdr euh noxfly mdrrrrr šŸ˜‚šŸ˜‚ merciiiii x)
18th Oct 2017, 7:58 PM
NoxFly
NoxFly - avatar
+ 5
Baguette ;)
18th Oct 2017, 8:09 PM
S e r e y n
+ 5
ouai mdr j'avoue on parlait tous anglais XDDD
18th Oct 2017, 8:19 PM
NoxFly
NoxFly - avatar
+ 4
xD
18th Oct 2017, 7:59 PM
Dapper Mink
Dapper Mink - avatar