Ardit Sula Ardit Sula - 27 days ago 8
CSS Question

How To Solve Bootstrap Grid Issue On mobile?

Im editing a description on Ebay listing Where no scripting is allowed.
The ebay description is embedded within the ebay template.

I've discovered that my #portfolio doesn't display correctly on mobile!

On the desktop it works absolutely fine as they are col-lg-3. On mobile ive used col-xs-6 as I would like a 2 x 2 grid.
The problem is that the last column gets dragged into another row.
See mobile image above displaying my issue.

Would anyone be able to teach me a new css trick that stops the last column getting sucked into a new row?

<div id="portfolio" class="container-fluid text-center ">
<h2><font color="#ce2065">the shills black mask</font><br><font size="1">&nbsp;</font></h2>
<div class="row">
<div class="col-sm-3 col-xs-6"> <img src="http://justbeauty-uk.s3.amazonaws.com/shillspoint1.jpg" class="img-responsive img-thumbnail img-circle margin" alt="Image" style="text-align: center; width: 60%;">
<p style="text-align: center;"><span style="line-height: 1.8;">The latest trend in skincare.&nbsp;</span>Proven results with the word’s best selling black mask - loved by beauty bloggers, as seen on YouTube</p>
</div>
<div class="col-sm-3 col-xs-6"> <img src="http://justbeauty-uk.s3.amazonaws.com/shillspoint2.jpg" class="img-responsive img-thumbnail img-circle margin" alt="Image" style="text-align: center; width: 60%;">
<p><span style="line-height: 1.8;">Activated charcoal quickly and effectively pulls blackheads from the root and aids skin regeneration. Promotes healthy skin too!</span></p>
</div>
<div class="col-sm-3 col-xs-6"> <img src="http://justbeauty-uk.s3.amazonaws.com/shillspoint3.jpg" class="img-responsive img-thumbnail img-circle margin" style="text-align: center; width: 60%;">
<p><span style="line-height: 1.8;">Brightening naturally-derived ingredients calendula, rosemary and grapefruit help restore a plump, youthful complexion.</span></p>
</div>
<div class="col-sm-3 col-xs-6"> <img src="http://justbeauty-uk.s3.amazonaws.com/shillspoint2.jpg" class="img-responsive img-thumbnail img-circle margin" style="text-align: center; width: 60%;" alt="Image">
<p><span style="line-height: 1.8;">Deeply penetrates the pores to remove acne-causing oil, which is also the main cause of acne outbreaks. Three more words.</span></p>
<p>
<br>
</p>
</div>
</div>
</div>


CSS:

/*Portfolio items*/


#portfolio .portfolio-item {
margin: 0 0 15px;
right: 0;
border: 1px outset rgba(255, 255, 255, 0.6);
}

#portfolio .portfolio-item:hover {
transition: 0.5s;
box-shadow: 5px 10px 5px rgba(0, 0, 0, 0.9);
}

#portfolio .portfolio-item .portfolio-link {
display: block;
position: relative;
max-width: 400px;
margin: 0 auto;
}

#portfolio .portfolio-item .portfolio-link .portfolio-hover {
background: rgba(0, 0, 0, .7);
position: absolute;
width: 100%;
height: 100%;
opacity: 0;
transition: all ease .5s;
-webkit-transition: all ease .5s;
-moz-transition: all ease .5s,
}

#portfolio .portfolio-item .portfolio-link .portfolio-hover:hover {
opacity: 1;
}

#portfolio .portfolio-item .portfolio-link .portfolio-hover .portfolio-hover-content {
position: absolute;
width: 100%;
height: 20px;
font-size: 20px;
text-align: center;
top: 50%;
margin-top: -12px;
color: #fff;
}

#portfolio .portfolio-item .portfolio-link .portfolio-hover .portfolio-hover-content i {
margin-top: -12px;
}

#portfolio .portfolio-item .portfolio-link .portfolio-hover .portfolio-hover-content h3,
#portfolio .portfolio-item .portfolio-link .portfolio-hover .portfolio-hover-content h4 {
margin: 0;
}

#portfolio .portfolio-item .portfolio-caption {
max-width: 400px;
margin: 0 auto;
background-color: rgba(0, 0, 0, 0.8);
text-align: center;
padding: 25px;
}

#portfolio .portfolio-item .portfolio-caption h4 {
color: #fff;
text-transform: none;
margin: 0;
}

#portfolio .portfolio-item .portfolio-caption p {
font-family: "Droid Serif", "Helvetica Neue", Helvetica, Arial, sans-serif;
font-style: italic;
font-size: 13px;
margin: 0;
}

#portfolio * {
z-index: 2;
}

@media (min-width:767px) {
#portfolio .portfolio-item {
margin: 0 0 30px;
}
}

Answer

To prevent objects from jumping You need to use clearfix wich is visible for xs viewports only. It looks like:

    <div class="clearfix visible-xs-block"></div>

So here is a resulting code:

<div id="portfolio" class="container-fluid text-center ">
    <h2><font color="#ce2065">the shills black mask</font><br><font size="1">&nbsp;</font></h2>
    <div class="row">
        <div class="col-sm-3 col-xs-6"> <img src="http://justbeauty-uk.s3.amazonaws.com/shillspoint1.jpg" class="img-responsive img-thumbnail img-circle margin" alt="Image" style="text-align: center; width: 60%;">
            <p style="text-align: center;"><span style="line-height: 1.8;">The latest trend in skincare.&nbsp;</span>Proven results with the word’s best selling black mask - loved by beauty bloggers, as seen on YouTube</p>
        </div>
        <div class="col-sm-3 col-xs-6"> <img src="http://justbeauty-uk.s3.amazonaws.com/shillspoint2.jpg" class="img-responsive img-thumbnail img-circle margin" alt="Image" style="text-align: center; width: 60%;">
            <p><span style="line-height: 1.8;">Activated charcoal quickly and effectively pulls blackheads from the root and aids skin regeneration. Promotes healthy skin too!</span></p>
        </div>
        <div class="clearfix visible-xs-block"></div>
        <div class="col-sm-3 col-xs-6"> <img src="http://justbeauty-uk.s3.amazonaws.com/shillspoint3.jpg" class="img-responsive img-thumbnail img-circle margin" style="text-align: center; width: 60%;">
            <p><span style="line-height: 1.8;">Brightening naturally-derived ingredients calendula, rosemary and grapefruit help restore a plump, youthful complexion.</span></p>
        </div>
        <div class="col-sm-3 col-xs-6"> <img src="http://justbeauty-uk.s3.amazonaws.com/shillspoint2.jpg" class="img-responsive img-thumbnail img-circle margin" style="text-align: center; width: 60%;" alt="Image">
            <p><span style="line-height: 1.8;">Deeply penetrates the pores to remove acne-causing oil, which is also the main cause of acne outbreaks. Three more words.</span></p>
            <p>
                <br>
            </p>
        </div>
    </div>
</div>