Couple things could help here with the bleeding off the sides issue, for one, the spacing matters inside of your pre element, so to avoid the large indent you have you could remove all of the white space caused by the indentation in your html.
Secondly, by default the code in pre tags do not wrap when the parent element gets too small to contain them. You have a few options that I can think of:
Make a scroll window to be able to view the runoff on mobile using overflow: hidden on the pre element
Lower the font size on smaller viewports to get to your desired width with media queries
Make the pre tag wrap, using white-space: pre-wrap on the pre element
I’m not sure if I understand your question about whether float is the best option for the hamburger icon, whatever works for positioning it where you want is probably okay.