Carlos Florian
Carlos Florian

Reputation: 171

Border spacing property not working

First of all, thanks for taking your time for this. I want to get this result - the same as you see on the image below:

Border spacing

I tried to implement 3 DIVs. First div like a container, and the other two DIV like columns.

The code for the main DIV I have created is:

.detacont {
border-top: 1px solid #c0c0c0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-webkit-flex-flow: row wrap;
-ms-flex-flow: row wrap;
margin-top: 20px;
padding-top: 7px;
}

The code for rest of DIVs are:

    .leftcol {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
width: 50%;
}

And

    .rightcol {

border-left: solid 1px #c0c0c0;
padding-left: 15px;

 }

Here is the HTML:

<div class="detacont">
<div class="detacont leftcol">
<div class="travel-price" itemprop="priceRange">
<span class="pricefrom">
Offer
</span>
<span class="pricelarge">
<span class="pricecurrency" itemprop="currenciesAccepted" content="USD">$</span>
<span class="pricenums">150</span>
<span class="pricenumsclose">per item</span>
</span>
</div>

And

<div class="detacont rightcol">
<div class="linkcls">
<a class="linkcliss" href="http://amazon.com" rel="nofollow" target="_blank">Buy Now</a>
</div>
</div>
</div>
</div>

I can't separate the TOP div border and here's what I'm getting. What I've missed?

enter image description here

Complete CSS code:

<style>

.detacont {
border-top: 1px solid #c0c0c0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-webkit-flex-flow: row wrap;
-ms-flex-flow: row wrap;
margin-top: 20px;
padding-top: 7px;
}
.detacont .leftcol {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
width: 50%;
padding-top: 7px;
}
.travel-price {
font-size: 2rem;
line-height: 2.2rem;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-webkit-flex-flow: row wrap;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
}
.pricefrom {
font-size: 1.7rem;
line-height: 2rem;
-webkit-align-content: flex-end;
-ms-flex-line-pack: end;
align-content: flex-end;
width: 100%;
}
.pricelarge {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
}
.pricecurrency {
font-size: 2rem;
line-height: 3.3rem;
-webkit-align-self: flex-start;
-ms-flex-item-align: start;
align-self: flex-start;
}
.pricenums {
font-size: 4.1rem;
line-height: 4.1rem;
}
.pricenumsclose {
color: #888;
-webkit-align-self: flex-end;
-ms-flex-item-align: end;
align-self: flex-end;
padding-bottom: .75rem;
}
.rightcol {

border-left: solid 1px #c0c0c0;
padding-left: 15px;

 }

.linkcls {
    font-size: 1.4rem;
    line-height: 1.8rem;
}
.linkcliss {
    font-size: 1.7rem;
    line-height: 2.5rem;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    background-color: #008385;
    color: #fff;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    min-height: 48px;
    padding: 8px 24px;
    text-align: center;
    -webkit-transition: color 200ms,background-color 200ms,border-color 200ms;
    transition: color 200ms,background-color 200ms,border-color 200ms;
    width: 100%;
}
</style>

Upvotes: 0

Views: 729

Answers (1)

besseddrest
besseddrest

Reputation: 155

detacont is a class that is applied on both leftcol and rightcol elements

<div class="detacont leftcol">
...
<div class="detacont rightcol">

The first rule for your detacont class is

border-top: 1px solid #c0c0c0;

So when you apply this class to the column elements, it brings with it all its CSS rules.

One way you can solve this is by giving the container a unique class with its own border-top rule.

Ex:

.container {
  border-top: 1px solid #c0c0c0; }

Upvotes: 1

Related Questions