I want to acomplish something like this:
And so far after hours of learning bootstrap and playing with the grid system I managed to do this:
Code that I use:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-body">
<div class="row-fluid">
<div class="col-md-4">
<img class="img-responsive" src="https://images-na.ssl-images-amazon.com/images/M/MV5BMTUxMDc1OTAzM15BMl5BanBnXkFtZTgwOTMwOTMyMDI#._V1_SY1000_CR0,0,674,1000_AL_.jpg" style="width: 130px; height: 200px">
</div>
<div class="col-md-8">
<div class="row">
<div class="text-title">Logan 2017</div>
<p>
Set in the future, Logan and Professor Charles Xavier must cope with the loss of the X-Men when a corporation lead by Nathaniel Essex is bent on destroying the world. With Logan's healing ...
</p>
</div>
<div class="row">
<button class="btn btn-warning btn-bold-text">IMDb</button>
<button class="btn btn-danger pull-right"><span class="glyphicon glyphicon-remove"></span></button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
As you can see, I want to be able to maximize the picture to the size of the panel, make buttons stick to bottom and fix the margin of the text.
Can someone help me ? Thanks!
I don't need anyone to do the code for me, just tell me what should I be looking for. Is there any spacing between columns in bootstrap ? I tried playing with margins and paddings but no chance of acomplishing what I want.
https://jsfiddle.net/0jv537r0/1/
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="well" style="position: relative; background: #fff;">
<div class="row">
<div class="col-xs-4">
<img class="img-responsive" src="https://images-na.ssl-images-amazon.com/images/M/MV5BMTUxMDc1OTAzM15BMl5BanBnXkFtZTgwOTMwOTMyMDI#._V1_SY1000_CR0,0,674,1000_AL_.jpg">
</div>
<div class="col-xs-8">
<div class="text-title">Logan 2017</div>
<p>
Set in the future, Logan and Professor Charles Xavier must cope with the loss of the X-Men when a corporation lead by Nathaniel Essex is bent on destroying the world. With Logan's healing ...
</p>
</div>
</div>
<button class="btn btn-warning btn-bold-text" style="position: absolute; bottom: 20px; left: 33.33333333%;">IMDb</button>
<button class="btn btn-danger pull-right" style="position: absolute; bottom: 20px; right: 20px;"><span class="glyphicon glyphicon-remove"></span></button>
</div>
</div>
</div>
</div>
So, I changed it to a well instead of a panel since you wern't actually using any of the panel elements other than the border. My answer isn't 100% full proof, you'd want to bring the styles not inline and add specifics for different screen widths, but in a nutshell at least you can see what I did to accomplish your goal. You could also use flexbox and then keep the buttons inside the col-xs-8 because with felxbox you could make the height of the col-xs-8 element match the height of the image.
Your "problem" is a commong one. Placing elements at the bottom of a parent element. There is generally not an out of the box solution to accomplish this. You must use position absolute. This position elements based on their closest non static parent. You could do this on the col-xs-8 element but because it's height won't match that of the image, that won't work you need to move the buttons outside the column. (Columns by default in Bootstrap have a non static position).
Now there are countless ways to accomplish what you wanted I just chose the route closet to what you had. I might suggest the media object (http://getbootstrap.com/components/#media) native to bootstrap. Wrap the media element in a wrapper with a border and you should be close to what you want, but really, media, panel, wells they are all similar. That is why in Bootstrap 4 they have all been removed in favor of cards. You might be better off going with BS4 as well. It's getting closer and closer to release and I have a site fully done with the current alpha and it's pretty solid. We're about to push the project to production too.
Related
We've built a website using bootstrap. We're checking the responsiveness of the site and have encountered an issue with an image "floating" on top of the page when we inspect the page and go to toggle device toolbar and change the setting to "iPad." Our site functions as expected on the desktop, mobile (galaxy, iPhone x, etc), and even iPad Pro settings.
.our-story {
color: #fff;
background-color: #67b7f2;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid pt-5">
<div class="row our-story">
<div class="col-md-6 offset-md-1 mb-3">
<h2 class="mt-5">We Move Lives</h2>
<p>Our process begins with asking a lot of questions and listening to your needs and concerns. Then we survey your entire home and assess everything that needs to be moved. We identify high-value, fragile items such as pianos, antiques, paintings, and chandeliers that will require special care. Finally, we create a detailed schedule for packing, loading, and delivery.</p>
<button type="button" class="btn btn-outline-tosa">Our Story</button>
</div>
<div class="col-md-4">
<img src="img/steve-justin-bruce-standup.png" class="img-fluid mt-5">
</div>
</div>
</div>
Ah ok, so yea I'd suggest something more like this, notice the margin -> padding changes and the flex-end on the img container cell. Without giving the image some sort of a bottom anchor it's just doing as expected.
Oh and embedding a button in an anchor is no bueno, Cheers
.our-story {
color: #fff;
background-color: #67b7f2;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row our-story">
<div class="col-md-6 offset-md-2 pb-3 pt-5">
<h2>We Move Lives</h2>
<p>Our process begins with asking a lot of questions and listening to your needs and concerns. Then we survey your entire home and assess everything that needs to be moved. We identify high-value, fragile items such as pianos, antiques, paintings, and chandeliers that will require special care. Finally, we create a detailed schedule for packing, loading, and delivery.</p>
<a class="btn btn-outline-tosa" href="about-us.html">Our Story</a>
</div>
<div class="col-md-4 d-flex flex-end justify-content-center pt-5">
<img src="https://picsum.photos/seed/picsum/200/300" class="img-fluid">
</div>
</div>
</div>
I'm trying to achieve masonry for my panels. This is how it looks currently:
I'd like it to fill the gaps whenever it's possible. I've tried using flexbox but it behave like there was 1 row and after adding more panels it just made them smaller. I also tried using column-countproperty but my panels were separated (panel heading from panel body. blue and white) unless there were as many elements in a row as there were columns (i.e. column-count: 4looked good only if number of panels was multiplicity of 4). Here's how my panel code looks:
<div class="container-fluid">
<div class="col-md-3 ng-cloak" ng-repeat="card in vm.cards" style="margin-bottom: 10px;">
<div class="panel panel-info" style="min-width:235px;">
<div class="panel-heading clearfix">
<h4 class="panel-title pull-left">{{ card.question }}</h4>
<div class="btn-group pull-right">
Manage
</div>
</div>
<div class="panel-body">
{{ card.answer }}
</div>
</div>
</div>
</div>
Here's the exact page in my repository: Github Reposiory
Also here's the working page: http://188.166.160.66/App/Demo
I'd like to achieve this with css, but if it's impossible I'll give js a shot.
If more screenshots are required I can provide them.
#Edit: I want to prevent my site from having horizontal scrolling.
I'm sure of the fact that I'm doing something so wrong, I tried to solve that this morning.
Here's the deal, I'm trying to build a responsive HTML page, that will have the behaviour of the picture you see below :
So I told myself, for the elements that have to be move like the elements below "Besoin d'un devis", etc, I will use a the boostrap grid, and use for that an WYSIWIG generator. But instead, when I try to resize the window here's what happens :
Without resizing the window - Normal behaviour :
When I resize the window and I try to test the boostrap grid :
I uploaded a test version in the internet so you can see my problem.
http://test-stackoverflow.co.nf
If you need the code, I will provide it. I just don't know a way to provide a whole "test website" and a case like this in stack.
<div class="container">
<div class="row">
<div class="col-sm-3">
<div class="content_block orange size_2">
<div class="icon fa fa-car"></div>
<div class="text">Auto</div>
</div>
</div>
<div class="col-sm-3">
<div class="content_block rose size_2">
<div class="icon fa fa-home"></div>
<div class="text">Habitation</div>
</div>
</div>
<div class="col-sm-2 col-md-3">
<div class="content_block green size_2">
<div class="icon fa fa-heart"></div>
<div class="text">Santé</div>
</div>
</div>
<div class="col-sm-2 col-lg-3"></div>
</div>
</div>
Try this out
I believe you are overwriting Bootstrap's grid system here:
<div class="container">
<div class="row">
<div class="col-sm-3">
<div class="content_block orange size_2">
<div class="icon fa fa-car"></div>
<div class="text">Auto</div>
</div>
</div>
<div class="col-sm-3">
<div class="content_block rose size_2">
<div class="icon fa fa-home"></div>
<div class="text">Habitation</div>
</div>
</div>
<div class="col-sm-2 col-md-3">
<div class="content_block green size_2">
<div class="icon fa fa-heart"></div>
<div class="text">Santé</div>
</div>
</div>
<div class="col-sm-2 col-lg-3"></div>
</div>
</div>
So, the columns are set, but then your size-2 style here:
.content_block.size_2 {
height: 200px;
width: 280px;
}
will overwrite that column's width.
Remove the width styling and it should work as intended. Please comment if additional help is needed.
Your problem is that you used class container instead of container-fluid in line 110. container has a fixed width, when you decrease your browser width, it stays the same and overflows its parent element. container-fluid has a width of 100%, so it fills your parent element.
Then you also have to adapt the images to 100% width (relative to the col-3) and a appropriate height.
EDIT:
.container has not a fixed width, but your .container-main# starts shrinking immediately because of its relative width, while .container shrinks not until your browser window hits 1200px width or less.
Your .container class is set to 970px. Set it to 100%. Also change the .col-sm-3 to .col-sm-4. Why? Well you 3 items, grid systems exist out of 12, 12/3 = 4.
Also set the width of the image to 100% to prevent overlapping.
As asked in the title, I am creating a website by using bootstrap v3.3.2.
The first question is that I am using the grid system to align the caption to the right of the thumbnail as shown below:
<div class="container">
<div class="thumbnail">
<div class="row">
<div class="col-md-6">
<a href="#">
<img class="img-responsive" src="images/pic.jpg">
</a>
</div>
<div class="col-md-6">
<div class="caption">
<h2>Title</h2>
<hr>
<p>A design specification provides explicit information about the requirements for a product and how the product is to be put together. It is the most traditional kind of specification, having been used historically in public contracting for buildings, highways, and other public works, and represents the kind of thinking in which architects and engineers have been trained.</p>
<hr>
<p class="caption-footer">
<span class="glyphicon glyphicon-heart"></span> Like it
<span class="glyphicon glyphicon-share"></span> Share it
</p>
</div>
</div>
</div>
</div>
</div>
Which turns out to be something like this:
As noticed, there is a large margin to the left of the image, which is not ideal. And when I resize the screen, it became more undesirable, with large margin to both side as shown below:
I think this may caused by the grid system since the col-md-6 has a fixed width. However I do not know how to fixe this.
The second question is that I try to align the two buttons to the bottom of the caption by adding a new class called caption-footer. However, this does not work.
Below is my CSS file for class caption-footer and how it turns out to be:
caption-footer{
position: absolute;
bottom:0;
left: 0;
}
I have checked quite a few links here (like: link1 link2). But none of them seems to work for my case.
Thanks in advance for any help!
One thing you can do simply place caption under col-md-12 div and buttons under another col-md-12 div.
<div class="container">
<div class="row">
<div class="col-md-6">
<a href="pulpitrock.jpg" class="thumbnail">
<p>Pulpit Rock: A famous tourist attraction in Forsand, Ryfylke, Norway.</p>
<img src="pulpitrock.jpg" alt="Pulpit Rock" width="284" height="213">
</a>
</div>
<div class="col-md-6">
<div class="col-md-12">
A design specification provides explicit information about the requirements for a product and how the product is to be put together. It is the most traditional kind of specification, having been used historically in public contracting for buildings, highways, and other public works, and represents the kind of thinking in which architects and engineers have been trained.
</div>
<div class="col-md-12">
Download
Images
</div>
</div>
</div>
</div>
I am trying to have my bootstrap 3.0 layout pin the content of the right column to the top, thus staying in place as the main content scrolls on. I have arrived at the following code, which blows up as I re-size the browser. Is there a way to do this?
<div class="col-md-10>main content</div>
<div class="col-md-2 container" style="padding: 15px 0px 10px 23px; position: fixed; right: 20px; top:75px">
Right column, stuck to the top
</div>
I am not really (engineer learning these techniques) a bootstrap or CSS guy, so if bootstrap doesn't support this - that is valuable information for me as well.
You can use affix on the content inside the right column..
<div class="col-md-10>main content</div>
<div class="col-md-2">
<div class="affix">..</div>
</div>
Here's an example Bootply that you may find useful: http://bootply.com/104413
Demo
You can do this by using the affix class.
<div class="well col-span-4" data-spy="affix">
<div class="btn btn-large btn-danger col-span-12">This is fixed</div>
</div>
Animation