Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Tracy Excell
Front End Web Development Techdegree Graduate 15,333 PointsWhat is the best way to position a chart.js onto a web page?
Hello,
I have created a few charts using chart.js and am trying to position them onto my webpage using css. However I am not having much luck. Below is what I was thinking, but if you know how to do this, I would appreciate your help, as my attempts are not yet working.
HTML
<div id="lineGraph" class="canvasContainer"> <!--opening lineGraph-->
<canvas id="myLineChart" max-height="300" max-width="800"></canvas>
</div><!--closing lineGraph-->
CSS
.canvas-container {
max-height: 300px;
max-width: 800px;
position: relative;
}
#myLineChart {
height: 200px;
width: 600px;
position: absolute;
left: 25%;
top: 25%;
}
1 Answer

Shaun Kelly
35,560 PointsHi Tracy,
Your class in the HTML doesn't match your class in the CSS:
class="canvasContainer" .canvas-container
This could be your issue
Shaun
Tracy Excell
Front End Web Development Techdegree Graduate 15,333 PointsTracy Excell
Front End Web Development Techdegree Graduate 15,333 PointsThank you