Collapse 4 bootstrap columns into 2 - html

Considering this footer:
<footer id="footer" class="dark" style="background-color:#220E2F !important;">
<div id="footer-container_k" style="margin: auto; display:block;" class="row">
<div class="col-md-2 col-xs-6 col-md-offset-2" style="position: relative; left:8%;" id="first">
<div class="buffer">
<p>About</p>
<!--<p>Careers</p>-->
<p>Press</p>
<p>Blog</p>
</div>
</div>
<div class="col-md-2 col-xs-6" style="position: relative; left:2%;" id="second">
<div class="buffer">
<p>Contact</p>
<p>Support</p>
<p>Elexa USA</p>
</div>
</div>
<div class="col-md-2 col-xs-6" style="position: relative; right:4%;" id="third">
<div class="buffer">
<p>Z-Wave Products</p>
<a href="https://domeha.com/guardian" target="blank" ><p>Guardian Products</p></a>
<p>How-Tos</p>
<!--<a href="/news" target="blank" ><p>Dome News</p></a>-->
</div>
</div>
<div class="col-md-2 col-xs-6" style="position: relative; right:10%;" id="last">
<div class="buffer">
<a href="https://www.youtube.com/channel/UCuqjZpsNcaWkbH6T1_PTQ3Q" target="blank" ><p>YouTube</p></a>
<a href="https://www.facebook.com/DomeByElexa" target="blank" ><p>Facebook</p></a>
<a href="https://twitter.com/DomeByElexa" target="blank" ><p>Twitter</p></a>
<a href="https://www.linkedin.com/company/16181754"target="blank" ><p>LinkedIn</p></a>
</div>
</div>
</div>
How would I refactor this to collapse into two columns instead of one without positioning them, like I am now? Positioning seems hacky and seems to break very easily.

Remove all the extra styles you added on and they will stack. However the order will be wrong because of the stacking. To reorder try the push and pull approach, mobile first.
http://www.bootply.com/DoMgBuRpDj
<div class="col-md-2 col-xs-6 col-md-push-2" id="third">..</div>
<div class="col-md-2 col-xs-6 col-md-pull-2" id="second">...</div>

Related

How to fill the gap of a div without using media query?

I'm using bootstrap cards to build this layout on desktop:
So far so good, at this width everything is ok as well:
But from this width to desktop width the container is not filled:
The HTML to build the card with the images is:
<div class="card h-60">
<div>
<div class="row box">
<div class="box-content formal">
<div class="col-md-12">
<img class="imageban" src="img/crm.png" />
<span><b>CRM</b></span>
</div>
</div>
<div class="box-right">
<a href="#">
<img class="img-responsive" src="img/img1.jpg"/>
</a>
</div>
</div>
</div>
<div>
<div class="row box">
<div class="box-content report">
<div class="col-md-12">
<img class="imageban" src="img/report.png" />
<span><b>Report</b></span>
</div>
</div>
<div class="box-right">
<a href="#">
<img class="imageban" src="img/img4.jpg"/>
</a>
</div>
</div>
</div>
<div>
<div class="row box">
<div class="box-content formal">
<div class="col-md-12">
<img class="img-responsive" src="img/formal_notices.png" />
<span><b>Formal Notices</b></span>
</div>
</div>
<div class="box-content text">
<a href="#">
Open the Formal <br>Notice Document <br>Library
</a>
</div>
</div>
</div>
</div>
And the CSS is only this line:
.row.box{
max-width: 345px;
}
I'm stuck in this, any help would be nice. Thanks.
You can remove the class .box and use the Bootstrap classes instead col-md-4 col-xs-12.

Dynamically Center Elements inside a Row

I have two Images with Links inside a row. Sometimes only one Image will be needed so I have added JSTL tags to verify that. The problem is when I'm displaying just one Image. Then they're not centered. Only when both the Images are available it's centered. How to tackle this?
<div class="row">
<c:if test="${content.facebookLink ne 'NO_FACEBOOK_LINK'}">
<div class="col-sm-3 col-sm-offset-3 col-xs-6">
<a href="${content.facebookLink}" target="_blank">
<img src="<c:url value="/resources/images/fb.png"/>">
</a>
</div>
</c:if>
<c:if test="${content.twitterLink ne 'NO_TWITTER_LINK'}">
<div class="col-sm-3 col-xs-6">
<a href="${content.twitterLink}" target="_blank">
<img src="<c:url value="/resources/images/twitter.png "/>">
</a>
</div>
</c:if>
</div>
Thanks.
Better way is to convert .col-sm-3.col-xs-6 to inline-block element and use text-center class to .row
.col-sm-3.col-xs-6 {
display: inline-block;
float:none;
width:auto;
}
img {
width: 100px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class=container>
<div class="row text-center">
<div class="col-sm-3 col-xs-6">
<a href="${content.facebookLink}" target="_blank">
<img src="https://placeholdit.imgix.net/~text?txtsize=28&txt=300%C3%97300&w=300&h=300">
</a>
</div>
<div class="col-sm-3 col-xs-6">
<a href="${content.twitterLink}" target="_blank">
<img src="https://placeholdit.imgix.net/~text?txtsize=28&txt=300%C3%97300&w=300&h=300">
</a>
</div>
</div>
</div>
<div class=container>
<div class="row text-center">
<div class="col-sm-3 col-xs-6">
<a href="${content.twitterLink}" target="_blank">
<img src="https://placeholdit.imgix.net/~text?txtsize=28&txt=300%C3%97300&w=300&h=300">
</a>
</div>
</div>
</div>
Found a simple solution. Omitted he columns from the dynamic elements.
<div class="row">
<div class="col-md-12">
<c:if test="${content.facebookLink ne 'NO_FACEBOOK_LINK'}">
<a href="${content.facebookLink}" target="_blank" style="display: inline">
<img src="<c:url value="/resources/images/fb.png"/>">
</a>
</c:if>
<c:if test="${content.twitterLink ne 'NO_TWITTER_LINK'}">
<a href="${content.twitterLinkk}" target="_blank" style="display: inline">
<img src="<c:url value="/resources/images/twitter.png "/>">
</a>
</c:if>
</div>
</div>
Works perfect.

4 Centered Images HTML/ CSS BOOTSTRAP

--FIRST IMAGE IS DESIRE OUTPUT---
I got it to work on my screen but when I put it on bigger monitor doesn't seem to scale right. Any Recommendations ?
<div style="margin-left: 100px;margin-right: 100px;">
<div class="container-fluid">
<div class="row">
<div class="col-sm-3">
<img src="img/NUESTROS EVENTOS -1.png">
</div>
<div class="col-sm-3">
<img s src="img/NUESTROS EVENTOS -2.png">
</div>
<div class="col-sm-3">
<img src="img/NUESTROS EVENTOS -3.png">
</div>
<div class="col-sm-3">
<img src="img/NUESTROS EVENTOS -5.png">
</div>
</div>
</div>
This is what I get with this other code, centers but can't get rid the spaces.
---THIS IS WHAT I GET---
<div class="row" style="margin-bottom: 70px;">
<!-- column -->
<div class="col-xs-6 col-sm-5cols wow bounceInLeft ">
<div class="thumbnail ">
<img src="img/NUESTROS EVENTOS -1.png">
</div>
</div>
<!-- column -->
<div class="col-xs-6 col-sm-5cols wow bounceInLeft ">
<div class="thumbnail">
<img src="img/NUESTROS EVENTOS -2.png">
</div>
</div>
<!-- column -->
<div class="col-xs-6 col-sm-5cols wow swing ">
<div class="thumbnail">
<img src="img/NUESTROS EVENTOS -3.png">
</div>
</div>
<!-- column -->
<!-- column -->
<div class="col-xs-6 col-sm-5cols wow bounceInRight ">
<div class="thumbnail">
<img src="img/NUESTROS EVENTOS -5.png">
</div>
</div>
</div>
You can use inline-block elements, I have created inline-block class to wrap img and gave text-center class to row to align images in center.
.row-custom .inline-block{
display:inline-block;
}
.row-custom .inline-block img{
max-width:100px
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row row-custom text-center">
<div class="inline-block">
<img src="https://placeholdit.imgix.net/~text?txtsize=28&txt=300%C3%97300&w=300&h=300">
</div>
<div class="inline-block">
<img s src="https://placeholdit.imgix.net/~text?txtsize=28&txt=300%C3%97300&w=300&h=300">
</div>
<div class="inline-block">
<img src="https://placeholdit.imgix.net/~text?txtsize=28&txt=300%C3%97300&w=300&h=300">
</div>
<div class="inline-block">
<img src="https://placeholdit.imgix.net/~text?txtsize=28&txt=300%C3%97300&w=300&h=300">
</div>
</div>
Don't need to change or add more into CSS, You can use the Bootstrap class:
<div class="row">
<div class="col-sm-3">
<img class="img-responsive center-block" src="img/NUESTROS EVENTOS -1.png">
</div>
<div class="col-sm-3">
<img class="img-responsive center-block" src="img/NUESTROS EVENTOS -2.png">
</div>
<div class="col-sm-3">
<img class="img-responsive center-block" src="img/NUESTROS EVENTOS -3.png">
</div>
<div class="col-sm-3">
<img class="img-responsive center-block" src="img/NUESTROS EVENTOS -5.png">
</div>
</div>
Do these 3 things to achieve the desire result-
1. Add .img-responsive class to your img tags as its a way to make images responsive in bootstrap framework. You can also check this link for reference .
2. Add width="100%" to images to take up full space available in the image.
3. Add nopadding class to columns so that it will remove the padding space.
Update your code as below:
.nopadding {
padding: 0 !important;
margin: 0 !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
<div class="col-xs-3 nopadding">
<img src="https://dummyimage.com/600x400/000/fff" width="100%" class="img-responsive">
</div>
<div class="col-xs-3 nopadding">
<img s src="https://dummyimage.com/600x400/000/fff" class="img-responsive" width="100%">
</div>
<div class="col-xs-3 nopadding">
<img src="https://dummyimage.com/600x400/000/fff" class="img-responsive" width="100%">
</div>
<div class="col-xs-3 nopadding">
<img src="https://dummyimage.com/600x400/000/fff" class="img-responsive" width="100%">
</div>
</div>
</div>

How to add some space between in col-md-4?

In my school project. I am trying to create a photo gallery like view but I need that between two photos some space comes the code is here
<div class="container">
<h2 style="text-align: center;">Physics</h2>
<br>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-2" style="background-color: aliceblue;">
<img class="img-responsive" class="thumbnail" class="img-center center-block" src="assets/GirishJain2.JPG" alt="Girish Jain">
<p style="text-align:justify;">
<b> Girish Jain</b> <br>
b.Tech,IIT-Delhi<br></br>
Exp 14 years
</p>
</div>
<div class="col-sm-6"></div>
<div class="col-md-2" style="background-color: lavender;">
<img class="img-responsive" src="assets/prateek.JPG" alt="Prateek Jain">
<p style="text-align:justify;">
<b> Prateek Jain</b> <br>
b.Tech-MNIT,Jaipu<br></br>
Exp 7 years
</p>
</div>
<div class="col-md-2" style="background-color: aliceblue;">
<img class="img-responsive" class="thumbnail" class="img-center center-block" src="assets/sidharthjain.JPG" alt="Siddharth Jain">
<p style="text-align:justify;">
<b> Sidharth Jain</b> <br>
b.Tech-MNIT,Jaipur<br></br>
Exp 14 years
</p>
</div>
</div>
</div>
and the pages like
below the physics section I want a some space between each photo
Allow the col-md-4 to continue to serve it's current purpose. You want the image to be inside of a div who's job will be to give space.
HTML
<div class="col-md-4 col-xs-4 col-sm-4">
<div class="image-padding">
<img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=Iame"/>
</div>
</div>
CSS
.image-padding {
padding: 5px;
}
.image-padding img {
width: 100%;
}
CodePen
http://codepen.io/Goosecode/pen/oxaEjR
use the below it will work fine with you wrap it inside your container div
<link href="https://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-md-6 col-xs-6 col-sm-6">
<img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=Iame&w=970"/>
</div>
<div class="col-md-6 col-xs-6 col-sm-6">
<img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=Iame&w=970"/>
</div>
</div>
<hr>
<!--for other images !-->
<div class="row">
<div class="col-md-4 col-xs-4 col-sm-4">
<img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=Iame"/>
</div>
<div class="col-md-4 col-xs-4 col-sm-4">
<img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=Iame"/>
</div>
<div class="col-md-4 col-xs-4 col-sm-4">
<img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=Iame"/>
</div>
</div>
This can be easily achieved using Bootstrap.
HTML
<div class="col-md-4" id="element">
Your Content.
</div>
CSS
#element {
padding-top: 5px;
padding-bottom: 5px;
padding-left: 5px;
padding-right: 5px;
}

Creating a complex image and grid-based layout in twitter bootstrap

This seems to be my 2nd question regarding Twitter Bootstrap Grid system - but I'm fumbled.
I'm trying to build an image gallery, where each slide has an interesting layout. The JavaScript part is no problem (yay jQuery!) - it is the CSS/HTML part I'm stuck with.
Here's what I got so far - jsfiddle
<div class="container" style="padding-top: 20px; position: relative; padding-bottom: 20%; height: 0; overflow: hidden">
<div class="flexslider" style="position: absolute; top: 0; left: 0; padding-top: 20px; padding-bottom: 20px; width: 100%; height: 100%">
<ul class="slides">
<li>
<!-- Slide #1 -->
<div class="row">
<div class="col-xs-offset-2 col-xs-3" style=""> <a href="#" class="thumbnail">
<img src="img/bg-blur/IMG_8446.jpg">
<div class="thumbtext"><h3>TEXT</h3></div>
</a>
</div>
<div class="col-xs-5">
<div class="row">
<div class="col-xs-4"> <a href="#" class="thumbnail">
<img src="img/bg-blur/IMG_8757.jpg">
<div class="thmbtxt">Description</div>
</a>
</div>
<div class="col-xs-4"> <a href="#" class="thumbnail">
<img src="img/bg-blur/IMG_8848.jpg">
<div class="thmbtxt">Description</div>
</a>
</div>
<div class="col-xs-4"> <a href="#" class="thumbnail">
<img src="img/bg-blur/IMG_8864k.jpg">
<div class="thmbtxt">Description</div>
</a>
</div>
<div class="col-xs-6"> <a href="#" class="thumbnail">
<img src="img/bg-blur/noga.jpg">
<div class="thmbtxt">Description</div>
</a>
</div>
<div class="col-xs-6"> <a href="#" class="thumbnail">
<img src="img/bg-blur/untitled-(1-of-11).jpg">
<div class="thmbtxt">Description</div>
</a>
</div>
</div>
</div>
<div class="col-xs-2"></div>
</div>
</li>
</ul>
</div>
</div>
If you notice, the left-most image takes up only 1 row. What I'm trying to do is automatically resize it (the block in which it is sitting in), so it takes up the entire height of the 2 rows. This way it would look neat and symetrical.
Any ideas or thoughts about this?