Nedal Jedidi
Nedal Jedidi

Reputation: 119

bootstrap columns and padding not working

i'am new with bootstrap , i wanted to have a specific organisation of my view , you can see it in the image , but the problem is i can't manage to have padding between my cols .

            <div class="container">

                 <div class="row">

                    <div class="col-sm-3" style='border-radius: 5px;border: 2px solid green;'>

                    <div class="row">
                        <div class="col-sm-12" style='border-radius: 5px;background-color:red;height:70px;'></div>
                        <div class="col-sm-12" style='border-radius: 5px;background-color:red;height:140px;'></div>
                        <div class="col-sm-12" style='border-radius: 5px;background-color:red;height:140px;'></div>
                        <div class="col-sm-12" style='border-radius: 5px;background-color:red;height:140px;'></div>                             

                    </div></div>    

                    <div class="col-sm-9" style='border-radius: 5px;border: 2px solid red;'>
                        <div class="row">
                            <div class="col-sm-4 " style='border-radius: 5px;background-color:red;height:220px;'></div>
                            <div class="col-sm-4" style='border-radius: 5px;background-color:red;height:220px;'></div>
                            <div class="col-sm-4" style='border-radius: 5px;background-color:red;height:220px;'></div>          

                    </div>  </div>  

                </div>


            </div>

and here is what i want to have and what i got with this code.

enter image description here

enter image description here

please help me with that :) thanks

Upvotes: 2

Views: 5302

Answers (3)

Freak
Freak

Reputation: 115

Maybe you could try this one > twitter bootstrap grid system. Spacing between columns, they have managed to answer this question.

also try this one: it renders space without adding extra divs.

<div class="row">
 <div class="col-md-6">
  <div class="col-md-12">
     Some Content.. 
  </div>
 </div>
 <div class="col-md-6">
  <div class="col-md-12">
     Some Second Content.. 
  </div>
 </div>
</div>

This will automatically render some space between the 2 divs.

Upvotes: 0

sumngh
sumngh

Reputation: 566

You this, it will definetly arrange the grid as you required according to the model.

    <head>
        <style>
            .col-sm-12 { margin:3px; width:280px;}
            .col-sm-3 { margin: 3px; }
        </style>
    </head>

    <body>
        <div class="container">
            <div class="outer row">
                <div class="col-sm-3" style='border-radius: 5px;border: 2px solid green;'>
                    <div class="row">
                        <div class="col-sm-12" style='border-radius: 5px;background-color:red;height:70px;'></div>
                        <div class="col-sm-12" style='border-radius: 5px;background-color:red;height:140px;'></div>
                        <div class="col-sm-12" style='border-radius: 5px;background-color:red;height:140px;'></div>
                        <div class="col-sm-12" style='border-radius: 5px;background-color:red;height:140px;'></div>

                    </div>
                </div>
                <div class="col-sm-8" style='border-radius: 5px;border: 2px solid red;'>
                    <div class="inner row">
                        <div class="horcols-4 col-sm-3 " style='border-radius: 5px;background-color:red;height:220px;'></div>
                        <div class="horcols-4 col-sm-3" style='border-radius: 5px;background-color:red;height:220px;'></div>
                        <div class="horcols-4 col-sm-3" style='border-radius: 5px;background-color:red;height:220px;'></div>
                    </div>
                    <div class="col-sm-1" >
                    </div>
                </div>
            </div>
        </div>
    </body>

Upvotes: 1

Dhaval Chheda
Dhaval Chheda

Reputation: 5177

try this code and see if it suffices

<style>
        .inner {
            box-sizing: border-box;
            padding: 1em;
        }

        .horcols-4.col-sm-3 {
            margin: 1.5em;
        }

    </style>
</head>

<body>

    <div class="container">

        <div class="outer row">

            <div class="col-sm-3" style='border-radius: 5px;border: 2px solid green;'>

                <div class="row">
                    <div class="col-sm-12" style='border-radius: 5px;background-color:red;height:70px;'></div>
                    <div class="col-sm-12" style='border-radius: 5px;background-color:red;height:140px;'></div>
                    <div class="col-sm-12" style='border-radius: 5px;background-color:red;height:140px;'></div>
                    <div class="col-sm-12" style='border-radius: 5px;background-color:red;height:140px;'></div>

                </div>
            </div>

            <div class="col-sm-9" style='border-radius: 5px;border: 2px solid red;'>
                <div class="inner row">
                    <div class="horcols-4 col-sm-3 " style='border-radius: 5px;background-color:red;height:220px;'></div>
                    <div class="horcols-4 col-sm-3" style='border-radius: 5px;background-color:red;height:220px;'></div>
                    <div class="horcols-4 col-sm-3" style='border-radius: 5px;background-color:red;height:220px;'></div>

                </div>
            </div>

        </div>


    </div>

</body>

Upvotes: 1

Related Questions