How to stop text-boxes in my custom block trailing past the block?
While creating this form in your custom module you set DIV class to form items which is textfield in your casy. All you will have to do is use #prefix &amp; #sufix
You will start your DIV class from #prefix before #type of form items &amp; close the DIV at #sufix.

Here is the example

$form['first_name'] = array(
  '#prefix' =&gt; '&lt;div class="demo-form"&gt;',
  '#title' =&gt; t('First Name'),
   '#type' =&gt; 'textfield',
  '#suffix' =&gt; '&lt;/div&gt;',
  '#maxlength' =&gt; 128,
  '#required' =&gt; TRUE,
);


Open the CSS file or create your own at your theme folder, but if you create your own then you will have to declare it in theme.info file.

Write CSS for the class demo-form which you have applied to the form element &amp; resize it as your wish. If you have created your own CSS file then don't forget to clear your cache.