Search code examples
twitter-bootstraphtmlscaffolding

bootstrap overlapping spans


I'm learning bootstrap and I'm having a little issue with responsiveness and resizing.

I have these two elements:

enter image description here

The problem comes when resizing the window, or even viewing it in an iPad/iPhone or some screen sizes, the spans overlap:

enter image description here

After enough squeeze it finally rearrange itself to the position that should've taken without overlapping:

enter image description here

Probably I'm missing something, because of my web programming newbness.

Here's my code:

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <link href="<?php echo base_url() ?>assets/css/bootstrap.css" rel="stylesheet">

    <meta charset="utf-8">

    <style type="text/css">

        body {
            background-color: #f5f5f5;
            font: 13px/20px normal Helvetica, Arial, sans-serif;
            color: #4F5155;
        }

        #aux{
            margin: 40px;
            height: 100%;
            padding-top: 40px;
        }

        #body{
            background-color: #fff;
        }

        .containerList{ border:2px solid #ccc; width:100%; height: 100px; }


    </style>
    <link href="<?php echo base_url() ?>assets/css/bootstrap-responsive.css" rel="stylesheet">
</head>
<body>


    <div id="aux">
        <div id="wrap">
            <div id="body" class="well">
                <div class="row-fluid">
                    <div class="span3">
                        <textarea id="limitedtextarea" name="limitedtextarea" rows="5" cols="40"></textarea><br>
                    </div>
                    <div id="otherPartFormId" class="span9" >
                        <div id="otherPartForm">
                            <div class="containerList"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="<?php echo base_url() ?>assets/js/bootstrap.min.js"></script>
</body>
</html>

Solution

  • The width of a <textarea> is defined by the number of cols="" by default. You can enforce its width by setting some value via CSS like width: 100px; in addition to the number of cols : the CSS defined width will override the number of cols.

    But in this case, you want to enforce a width based on the fluid grid, as shown by the .row-fluid container. So you should apply the .span12 class to the <textarea> like this :

    Demo (jsfiddle)

    <div class="row-fluid">
        <div class="span3">
            <textarea class="span12" id="limitedtextarea" name="limitedtextarea" rows="5" cols="40"></textarea><br>
        </div>
        <div id="otherPartFormId" class="span9" >
            <div id="otherPartForm">
                <div class="containerList"></div>
            </div>
        </div>
    </div>