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?
Related
I have a 9-cell grid containing images (using bootstrap columns). The grid works fine and is responsive when it contains images only. However, my goal is to make the images clickable, hence I placed the <img> tag inside an anchor tag <a>, which resulted in the photos getting out of the grid order.
When I clicked on "Inspect" on Chrome, it showed the <a> as a large container, with the <img> centered inside of it. How do I make the <a> element adhere to bootstrap column sizes?
HTML:
<div class="container">
<div class="row">
<a href="#">
<img class="col-md-6 col-lg-4 gallery-photo" src="https://" alt="something">
</a>
<a href="#">
<img class="col-md-6 col-lg-4 gallery-photo" src="https://" alt="something">
</a>
<a href="#">
<img class="col-md-6 col-lg-4 gallery-photo" src="https://" alt="something">
</a>
</div>
</div>
CSS:
.gallery-photo {
object-fit: cover;
height: 300px;
margin: 1% 0;
}
The columns are supposed to be placed directly inside of a row.
So it should look something like this.
<div class="container">
<div class="row">
<div class="col-md-6 col-lg-4">
<a href="#">
<img class="gallery-photo" src="https://" alt="something">
</a>
</div>
<div class="col-md-6 col-lg-4">
<a href="#">
<img class="gallery-photo" src="https://" alt="something">
</a>
</div>
<div class="col-md-6 col-lg-4">
<a href="#">
<img class="gallery-photo" src="https://" alt="something">
</a>
</div>
</div>
</div>
Try adding the bootstrap columns to the a tag and not the img.
<div class="container">
<div class="row">
<a class="col-md-6 col-lg-4" href="#">
<img class="gallery-photo" src="https://" alt="something">
</a>
<a class="col-md-6 col-lg-4" href="#">
<img class="gallery-photo" src="https://" alt="something">
</a>
<a class="col-md-6 col-lg-4" href="#">
<img class="gallery-photo" src="https://" alt="something">
</a>
</div>
</div>
Bootstrap columns should be placed directly inside of a row.
Your links need to go inside of the bootstrap columns if you want them to be constrained by the bootstrap column sizes.
In addition, you should put width: 100% on your images for object-fit to work the way you want it to.
.gallery-photo {
object-fit: cover;
width: 100%;
height: 300px;
margin: 1% 0;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-md-6 col-lg-4">
<a href="#">
<img class="gallery-photo" src="https://placeimg.com/1100/750/nature" alt="something">
</a>
</div>
<div class="col-md-6 col-lg-4">
<a href="#">
<img class="gallery-photo" src="https://placeimg.com/1100/750/nature" alt="something">
</a>
</div>
<div class="col-md-6 col-lg-4">
<a href="#">
<img class="gallery-photo" src="https://placeimg.com/1100/750/nature" alt="something">
</a>
</div>
</div>
</div>
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.
My images are stretching into the padding/margin that bootstrap uses to divide the columns. I want to keep the columns divided but not have the images stretch. I have been able to shrink the image using padding but then the whitespace between the columns is clickable which is not what I want.
<div id="cont_divider" class="container">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-3 col_divide">
<div class="row text_center">
<a href="#" class="image_link_styling">
<div class="col-md-12">
<div id="inner_cont_1">
<div class="row">
<p class="stair_image_font_style">Straight<br/>Staircase</p>
<img class="img-responsive staircase_imgs" src="<?php bloginfo('template_directory'); ?>/images/straight.jpg" alt="straight staircase">
</div>
</div>
</div>
</a>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col_divide">
<div class="row text_center">
<a href="#" class="image_link_styling">
<div class="col-md-12">
<div id="inner_cont_2">
<div class="row">
<p class="stair_image_font_style">Single Winder<br/>Staircase</p>
<img class="img-responsive staircase_imgs" src="<?php bloginfo('template_directory'); ?>/images/single_winder.jpg" alt="straight staircase">
</div>
</div>
</div>
</a>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col_divide">
<div class="row text_center">
<a href="#" class="image_link_styling">
<div class="col-md-12">
<div id="inner_cont_3">
<div class="row">
<p class="stair_image_font_style">Double Winder<br/>Staircase</p>
<img class="img-responsive staircase_imgs" src="<?php bloginfo('template_directory'); ?>/images/double_winder.jpg" alt="straight staircase">
</div>
</div>
</div>
</a>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col_divide">
<div class="row text_center">
<a href="#" class="image_link_styling">
<div class="col-md-12">
<div id="inner_cont_4">
<div class="row">
<p class="stair_image_font_style">Triple Winder<br/>Staircase</p>
<img class="img-responsive staircase_imgs" src="<?php bloginfo('template_directory'); ?>/images/triple_winder.jpg" alt="straight staircase">
</div>
</div>
</div>
</a>
</div>
</div>
</div>
</div>
CSS:
#inner_cont_1{
background-color: #336699;
}
#inner_cont_2{
background-color: #cc6633;
}
#inner_cont_3{
background-color: #ff6633;
}
#inner_cont_4{
background-color: #ffcc66;
}
.staircase_imgs{
box-sizing: border-box;
width: 100%;
display: block;
padding: 0 1.238em 0.3em 1.238em;
}
.stair_image_font_style{
font-size: 2em;
color: #ffffff;
line-height: 1em;
padding: 0.8em 0.938em;
margin: 0;
}
.col_divide{
margin-top: 1em;
margin-bottom: 1em;
}
That's because you're using .row without a .col- class. .row has negative left and right margins which will extend the content area out beyond the parent. The padding of a .col- class nullifies this affect. Remove .row.
#import url( 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' );
#inner_cont_1 {
background-color: #336699;
}
#inner_cont_2 {
background-color: #cc6633;
}
#inner_cont_3 {
background-color: #ff6633;
}
#inner_cont_4 {
background-color: #ffcc66;
}
.stair_image_font_style {
font-size: 2em;
color: #ffffff;
line-height: 1em;
padding: 0.8em 0.938em;
margin: 0;
}
.col_divide {
margin-top: 1em;
margin-bottom: 1em;
}
<div id="cont_divider" class="container">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-3 col_divide">
<div class="row text_center">
<div class="col-md-12">
<a href="#" class="image_link_styling">
<div id="inner_cont_1">
<p class="stair_image_font_style">Straight<br/>Staircase</p>
<img class="img-responsive" src="http://placehold.it/600x400/fc0" alt="straight staircase">
</div>
</a>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col_divide">
<div class="row text_center">
<div class="col-md-12">
<a href="#" class="image_link_styling">
<div id="inner_cont_2">
<p class="stair_image_font_style">Single Winder<br/>Staircase</p>
<img class="img-responsive" src="http://placehold.it/600x400/fc0" alt="straight staircase">
</div>
</a>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col_divide">
<div class="row text_center">
<div class="col-md-12">
<a href="#" class="image_link_styling">
<div id="inner_cont_3">
<p class="stair_image_font_style">Double Winder<br/>Staircase</p>
<img class="img-responsive" src="http://placehold.it/600x400/fc0" alt="straight staircase">
</div>
</a>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col_divide">
<div class="row text_center">
<div class="col-md-12">
<a href="#" class="image_link_styling">
<div id="inner_cont_4">
<p class="stair_image_font_style">Triple Winder<br/>Staircase</p>
<img class="img-responsive" src="http://placehold.it/600x400/fc0" alt="straight staircase">
</div>
</a>
</div>
</div>
</div>
</div>
</div>
P.S. I also removed your .staircase_imgs class as it's not required once you remove the .row elements. I also rearranged some of your markup like a to inside the Bootstrap column element. This way the white space around the column element isn't clickable.
Remove the extra <div class="row"> you have. This creates margin: 0 -15px; for .col to rest in, but you do not have a -col in this .row ... so simply remove it.
Like this:
<div class="col-xs-12 col-sm-6 col-md-3 col_divide">
<div class="row text_center">
<a href="#" class="image_link_styling">
<div class="col-md-12">
<div id="inner_cont_3">
<div class="row"> <!-- REMOVE THIS DIV -->
<p class="stair_image_font_style">Double Winder<br/>Staircase</p>
<img class="img-responsive staircase_imgs" src="<?php bloginfo('template_directory'); ?>/images/double_winder.jpg" alt="straight staircase">
</div>
</div>
</div>
</a>
</div>
</div>
First of all, you should place your a tag inside bootstrap column, in order to be inside that padding column. Second, you added unnecessary .row classes.
Your structure should be something like this:
<div class="col-xs-12 col-sm-6 col-md-3 col_divide">
<div class="row text_center">
<div class="col-md-12">
<div id="inner_cont_1">
<a href="#" class="image_link_styling">
<p class="stair_image_font_style">Straight<br/>Staircase</p>
<img class="img-responsive staircase_imgs" src="<?php bloginfo('template_directory'); ?>/images/straight.jpg" alt="straight staircase">
</a>
</div>
</div>
</div>
</div>
I made a fiddle with your code: fiddle
Hope this helps!
your <a> tag starts way outside of the <img> tag. Instead of using the link over the multiple <div>'s try placing the <a> tag just around the <img> See the example below:
<div class="col-md-12">
<a href="..">
<img src="..." class="img-responsive">
</a>
</div>
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>
I want to implement navigation with nav-pills class on my website but when I use the code below, buttons in navigation are too big. I would like to change its height. Any solution?
<div class="row">
<div class="box">
<div class="col-sm-12 text-center">
<ul class="nav nav-pills">
<li role="presentation" class="active">Rekonstrukce</li>
<li role="presentation">Zemní práce</li>
<li role="presentation">Rodinné domy</li>
</ul>
</div>
<div class="col-sm-4 text-center">
<a href="#" class="thumbnail" data-toggle="modal" data-target="#lightbox">
<img class="img-responsive" src="img/rekonstrukce/pic1.jpg" alt="">
</a>
</div>
<div class="col-sm-4 text-center">
<img class="img-responsive" src="http://placehold.it/750x450" alt="">
</div>
<div class="col-sm-4 text-center">
<img class="img-responsive" src="http://placehold.it/750x450" alt="">
</div>
<div class="clearfix"></div>
</div>
</div>
Add this in your css:
.nav>li>a {
padding: 4px 6px !important;
}
(Adjust the padding values according to the size you need)