0

I am trying to set three divs side by side with each equal width and height. I am unable to remove that extra space at right at right most div. If I set its margin-right to 0 the rightmost div becomes bigger than other two.

Here is the fiddle.

Css:

 .recordpopup {
        position: fixed;
        z-index: 10000;
        top: 0;
        left: 0;
        height: 100%;
        width: 100%;
        background-color: rgba( 0, 0, 0, .8);
        background-position: 50% 50%;
        background-repeat: no-repeat;
        display: block;
    }

    .recordpopup .retry {
        background-color: black;
        border: 1px solid white;
        xborder-radius: 8px;
        box-sizing: border-box;
        color: white;
        font-family: ProximaNova-Regular;
        font-size: 16px;
        font-weight: bold;
        xheight: 50px;
        margin-left: auto;
        margin-right: auto;
        padding-top: 0px;
        position: relative;
        text-align: center;
        top: 30%;
        width: 40%;
        z-index: 15000;
        border-radius: 8px;
        padding: 20px 10px;
        background-image: url('images/gray_bar.png');
        background-repeat: repeat-x;
        background-color: white;
    }

    #product-wrapper {
        overflow: hidden;
        margin-top: 25px;
    }

    .product {
        float: left;
        width: 33%;
        display: table-cell;
        width: 33.33333333%;
    }

    .product .container {
        margin-right: 10px;
        padding: 10px;
        background-color: #000;
    }

    .product .container img {
        display: block;
        margin: 0 auto;
        width: 100%;
    }

    #closeRecord {
        background: black none repeat scroll 0 0;
        border: 2px solid white;
        border-radius: 50%;
        color: white;
        cursor: pointer;
        height: 25px;
        right: -15px;
        left: right;
        position: absolute;
        top: -10px;
        width: 25px;
    }

Html:

<div class="recordpopup">
        <div class="retry">
            <div id="closeRecord">x</div>
            <div style="width: 100%;text-align: left;margin: 5px 0;font-size: 12px;color:#333;"><span class="TitleText">Lorem Ipsum Lorem Ipsum</span> </div>
            <div id="product-wrapper">
                <div class="product">
                    <div class="container">
                        <img src="images/circle.png">
                        <p>Dummy</p>
                    </div>

                </div>
                <div class="product">
                    <div class="container">
                        <img src="images/circle.png">
                        <p>Dummy</p>
                    </div>
                </div>
                <div class="product">
                    <div class="container">
                        <img src="images/circle.png">
                        <p>Dummy</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
Sonali
  • 2,223
  • 6
  • 32
  • 69
  • So do you want to place your third to right with no space? and where you are doing margin-right to 0? – Ravi Ubana May 24 '17 at 15:42
  • Possible duplicate of [How do I keep two divs that are side by side the same height?](https://stackoverflow.com/questions/2997767/how-do-i-keep-two-divs-that-are-side-by-side-the-same-height) – Rob May 24 '17 at 16:01

3 Answers3

1

Here is my solution.

The key is removing the margin-right: 10px and adding

    .product:nth-child(1) .container{
      margin-right:5px;
    }
    .product:nth-child(2) .container{
      margin: 0 5px 0 5px;
    }
    .product:nth-child(3) .container{
      margin-left: 5px;
    }

JSFiddle ===> https://jsfiddle.net/kjkk3f9d/1/

0

check out my fiddle:

https://jsfiddle.net/kjkk3f9d/2/

the important styles are

    #product-wrapper {
        overflow: hidden;
        margin-top: 25px;
        display: flex;
        justify-content: space-between;
    }

    .product {
        flex-basis:0;
        flex: 1 1 auto;
        margin: 5px;
    }
Ben Lonsdale
  • 675
  • 5
  • 11
0

The margin-right: 10px was pushing out your divs, replace it with margin: 0 5px to give a uniform look

.product .container {
            margin: 0px 5px;
            padding: 10px;
            background-color: #000;
        }

https://jsfiddle.net/kjkk3f9d/3/

gaynorvader
  • 2,619
  • 3
  • 18
  • 32