2

I know this was asked many times in SO but I can't find the answer for my question. I used bootstrap with this one and tried to have a two six columns in a row. It works as expected but what I want to achieve is that I wanted to out a gap between them. To see what I mean you can check it here. I don't want to override the bootstrap cols here. I wanted to use only the added class which is survey-extra.

HTML

<div class="container">
 <div class="row visit-redeem text-center">
   <h5>Visit Site To Redeem</h5>
 </div>
  <div class="row">
  <div class="col-xs-6 survey-extra">
    <h5>FROM OUR SPONSORS</h5>
    <span class="money-extra">$0.00</span>
  </div>

  <div class="col-xs-6 survey-extra">
    <h5>FREEBIES</h5>
    <span class="money-extra">$0.00</span>
  </div>
</div>
</div>

CSS

 .survey-extra {
        background: #1e90ff;
        color: #fff;
        padding: 5px;
        border-radius: 10px;
        text-transform: uppercase;
    }
.visit-redeem {
  background: #56a4da;
  margin-top: 5px;
  margin-bottom: 6px;
  color: #fff;
  padding: 5px;
  border-radius: 20px 20px 0 0;
  text-transform: uppercase;
}

I also tried the CSS3 :nth-of-type() Selector but no luck!

I wanted to do this using css only.

claudios
  • 6,588
  • 8
  • 47
  • 90
  • Possible duplicate of [How to adjust gutter in Bootstrap 3 grid system?](http://stackoverflow.com/questions/19911763/how-to-adjust-gutter-in-bootstrap-3-grid-system) – Wim Mertens Jul 29 '16 at 03:36
  • @WimMertens, thanks for the help but that's not the answer I am looking for. I don't want to override and use the bootstrap cols here. What I wanted here is to only use the added class `survey-extra`. – claudios Jul 29 '16 at 03:43
  • ok, have added an answer, hopefully this is what you're after – Wim Mertens Jul 29 '16 at 04:05

5 Answers5

0

Try putting survey-extra within col-xs-6 instead. Hope that help

.survey-extra {
    background: #1e90ff;
    color: #fff;
    padding: 10px;
    border-radius: 10px;
    text-transform: uppercase;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
  <div class="row">
    <div class="col-xs-6">
      <div class="survey-extra">
          <h5>FROM OUR SPONSORS</h5>
          <span class="money-extra">$0.00</span>
      </div>
    </div>

    <div class="col-xs-6">
      <div class="survey-extra">
          <h5>FREEBIES</h5>
          <span class="money-extra">$0.00</span>
      </div>
    </div>
  </div>
</div>
Kenny Chan
  • 1,232
  • 1
  • 15
  • 20
0

I was able to put a visual space between the two divs by using CSS to set the width of .survey-extra to a percentage and then giving either one of the divs (using the :nth-of-type() Selector) or both of them margins, like this:

.survey-extra {
    width: 45%;
    margin-right: 5px;
    background: #1e90ff;
    color: #fff;
    padding: 5px;
    border-radius: 10px;
    text-transform: uppercase;
}

Check it out on JSFiddle. Of course you'd have to play around with the width percentage and margins to get exactly what you want.

If you don't want to use margins, you could also keep the width set to a percentage and then use floating, like this:

.survey-extra {
    background: #1e90ff;
    color: #fff;
    width: 45%;
    padding: 5px;
    border-radius: 10px;
    text-transform: uppercase;
}

.survey-extra:nth-of-type(0) {
  float: left;
}

.survey-extra:nth-of-type(1) {
  float: right;
}

Check it out using floating on fiddle

Xetnus
  • 353
  • 2
  • 4
  • 13
0

I found a solution for my problem and I would like to share it to you for future references. What I did is add nth-of-type(2) and applied css.

CSS:

.survey-extra {
    background: #1e90ff;
    color: #fff;
    padding: 5px;
    border-radius: 10px;
    text-transform: uppercase;
}

.survey-extra:nth-of-type(2) {
  width: 49%;
  float: right;
}

.visit-redeem {
  background: #56a4da;
  margin-top: 5px;
  margin-bottom: 6px;
  color: #fff;
  padding: 5px;
  border-radius: 20px 20px 0 0;
  text-transform: uppercase;
}

HTML:

<div class="container">
  <div class="row visit-redeem text-center">
    <h5>Visit Site To Redeem</h5>
  </div>
  <div class="row">
  <div class="col-xs-6 survey-extra">
    <h5>FROM OUR SPONSORS</h5>
    <span class="money-extra">$0.00</span>
  </div>

  <div class="col-xs-6 survey-extra">
    <h5>FREEBIES</h5>
    <span class="money-extra">$0.00</span>
  </div>
</div>
</div>

fiddle here

claudios
  • 6,588
  • 8
  • 47
  • 90
0
.survey-extra {
  display: inline-block;
  float: none;
  margin: 0 2% 2% 0;
  width: 49%;
}

.survey-extra:last-child {
  margin-right: 0;
}

And if you have more than 1 row you can replace last-child with nth-child(2n)

Wim Mertens
  • 1,780
  • 3
  • 20
  • 31
0

no need to change in css just change html like below:

<div class="container">
    <div class="row visit-redeem text-center">
        <h5>Visit Site To Redeem</h5>
    </div>
    <div class="row">
        <div class="col-xs-6">
            <div class="survey-extra">
                <h5>FROM OUR SPONSORS</h5>
                <span class="money-extra">$0.00</span>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="survey-extra">
                <h5>FREEBIES</h5>
                <span class="money-extra">$0.00</span>
            </div>
        </div>
    </div>
</div>
dr. strange
  • 665
  • 7
  • 22