-1

I need some help. I would like to make to these two divs, participation and benefits, sit side by side each other horizontally, but I can only edit the CSS code. Here's what I have so far:

.supporting {
  padding: 150px;
  margin-bottom: 40px;
  margin-right: 10px;
}

.participation {
  margin: 10px 0px 0px 0px;
  width: 400px;
  height: 400px;
  background-color: lightgray;
  padding: 30px;
  position: relative;
}

#zen-participation {
  clear: both;
  float: left;
  padding-left: 30px;
  padding-top: 10px;
}

.benefits {
  margin: 10px 0px 0px 0px;
  padding: 30px;
  background-color: lightcoral;
  background-repeat: no-repeat;
  position: relative;
  width: 80%;
}

#zen-benefits {
  clear: both;
  float: right;
  width: 30%;
  padding-left: 30px;
  padding-top: 50px;
}
<div class="main supporting" id="zen-supporting" role="main">

  <div class="participation" id="zen-participation" role="article">
    <h3>Participation</h3>
    <p>Strong visual design has always been our focus.....</p>
  </div>

  <div class="benefits" id="zen-benefits" role="article">
    <h3>Benefits</h3>
    <p>Why participate? ...</p>
  </div>

</div>
disinfor
  • 10,865
  • 2
  • 33
  • 44
Marie
  • 5
  • 2
  • I would focus on the `flex-box` answers from that duplicate question. https://stackoverflow.com/a/34486579/1172189 – disinfor Nov 05 '20 at 20:54
  • There are [thousands of questions about making divs sit next to each other](https://stackoverflow.com/search?q=divs+side+by+side+%5BCSS%5D). Please read [ask], specifically the first section titled "Search, and research..." – Heretic Monkey Nov 05 '20 at 21:01

3 Answers3

0

you can do it in a multitude of ways, one would be:

add to the parent (.main / .supporting), the following rules

display: flex
flex-direction: row

Like so:

.supporting {
  display: flex;
  flex-direction: row;
  padding: 150px;
  margin-bottom: 40px;
  margin-right: 10px;
}
Capagris
  • 3,811
  • 5
  • 30
  • 44
0

Try using float right in your benefits div and change your participation position to absolute:

.benefits
{
    margin: 10px 0px 0px 0px;
    padding: 30px;
    background-color: lightcoral;
    background-repeat: no-repeat;
    float: right;
    position: relative;
    width: 80%;
}


.participation {
  margin: 10px 0px 0px 0px;
  width: 400px;
  height: 400px;
  background-color: lightgray;
  padding: 30px;
  position: absolute;
}
Mamdlv
  • 540
  • 8
  • 23
0

You can use flexbox.

Set the parent .supporting div to display: flex;

.supporting {
  display: flex;
  padding: 150px;
  margin-bottom: 40px;
  margin-right: 10px;
}

.participation {
  margin: 10px 0px 0px 0px;
  width: 400px;
  height: 400px;
  background-color: lightgray;
  padding: 30px;
  position: relative;
}

#zen-participation {
  clear: both;
  float: left;
  padding-left: 30px;
  padding-top: 10px;
}

.benefits {
  margin: 10px 0px 0px 0px;
  padding: 30px;
  background-color: lightcoral;
  background-repeat: no-repeat;
  position: relative;
  width: 80%;
}

#zen-benefits {
  clear: both;
  float: right;
  width: 30%;
  padding-left: 30px;
  padding-top: 50px;
}
<div class="main supporting" id="zen-supporting" role="main">

  <div class="participation" id="zen-participation" role="article">
    <h3>Participation</h3>
    <p>Strong visual design has always been our focus.....</p>
  </div>

  <div class="benefits" id="zen-benefits" role="article">
    <h3>Benefits</h3>
    <p>Why participate? ...</p>
  </div>

</div>
Aib Syed
  • 3,118
  • 2
  • 19
  • 30