2

I have a blog page, I am using col-md-8, Inside col-md-8 my content exists, But I wanna stretch one of my div to be stretch to full width which is in col-md-8. My page

enter image description here

I wanna make it stretch, My code:

.joinUs {
  width: 100vw;
  margin-left: -33.333333%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<section>
  <div class="container">
    <div class="row justify-content-center">
      <div class="col-md-8">
        <div class="article--publishedDate smallText text-uppercase">
          Published : 02 June 2019
        </div>
        <div class="article--topDescription mt-54px">
          In the above video, I have talked about top font management apps for Windows and Mac OS. Most of the Windows Font Management apps are Free and for Mac most of them are paid. I have talked about the top apps for Windows and Mac.
        </div>

        // I wanna make it stretch to full width of the browser
        <div class="joinUs">
          <div class="row">
            <div class="col-md-8">
              <div class="sectionTitle allCaps-Bold">
                <span>Start learning for FREE Today - Visual Design Class</span>
              </div>
            </div>
            <div class="col-md-4">
              <div class="joinUs--title">
                Join my community of <span>41257</span> students from <span>170</span> countries worldwide.
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>

But it doesn't work

enter image description here

Please help me, I am stuck

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122

2 Answers2

1

Check this. Hope this helps. There is two way to achieve this,

  1. negative-margin and VW-width
  2. content in a fixed with container but let :before :after to achieve the fullwidth effect. ( The Blue One )

/*Container style is for illustration purpose only */

.container {
  background: gray;
  min-height: 400px;  margin-bottom: 100px;
}


/*Can achive using vw css unit*/
.row-full {
  width: 100vw;
  position: relative;
  margin-left: -50vw;
  height: 100px;
  margin-top: 100px;
  left: 50%;
}

/*<!--- 2nd way --> */

.content_box {
    padding: 54px 0 21px;
    color: #fff;
    background-color: #88bae1;
    margin-bottom: 145px;
    position: relative;
    z-index: -1;
}
 .content_box:before {
    content: "";
    position: absolute;
    height: 100%;
    left: -3000px;
    right: -3000px;
    background-color: #88bae1;
    z-index: -1;
    top: 0;
    bottom: 0;
    width: auto !important;
}
<div class="container">
    
    <div class="row" style="height:100px; background: #fff;"> this is ok</div>
    <div class="row row-full" style="height:100px; background: #f00;">
        this should take 100% width
    </div>
</div>


<!--- 2nd way --> 


<div class="content_box">
<div>Lorem ipsum</div>
</div>

Solution of your problem

.joinUs:before {
    content: "";
    position: absolute;
    height: 100%;
    left: -3000px;
    right: -3000px;
    background-color: #ebf0f8;
    z-index: -1;
    top: 0;
    bottom: 0;
    width: auto !important;
}

and body{overflow-x: hidden;}

Kevin
  • 1,241
  • 7
  • 20
1

after few hit and trial I found the solution:

.joinUs {
    width: calc(100vw - 50px);
    margin-left: -27%;
    padding: 20px 15px;
}

the problem with margin-left: -33.333333%; is that the percentage is based on the width of the container which in this case is your col-md-8, not the viewport. Also the child element row stretches the width by 30px because of margin-left: -15px; and margin-right: -15px; which could result in horizontal scrollbar on page. To avoid the scrollbar I added padding: 20px 15px; to compansate the negative margins by row.

Going through your website I found out that you are overriding Bootstrap's original classes. Never do that!

Instead Always create your own classes

Sushmit Sagar
  • 1,412
  • 2
  • 13
  • 27