So I'm using the Bootstrap Thumbnail grid system, everything is looking ok apart from the images seem to be overlapping and I can't work out why? I've attached an image too.
When I'm hovering over the images the images in the middle are overlapping each other? I don't know if I'm being completely stupid or it's a bootstrap default I just can't win at?
HTML
<div class="top-header"class="page-header">
<h1>Smile Board</h1>
</div>
<div class="container">
<div class="row">
<div class="col-lg-12">
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="#">
<img class="img-responsive" src="./images/image01.png" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="#">
<img class="img-responsive" src="./images/image02.png" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="#">
<img class="img-responsive" src="./images/image03.png" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="#">
<img class="img-responsive" src="./images/image04.png" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="#">
<img class="img-responsive" src="./images/image05.png" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="#">
<img class="img-responsive" src="./images/image06.png" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="#">
<img class="img-responsive" src="./images/image07.png" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="#">
<img class="img-responsive" src="./images/image08.png" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="#">
<img class="img-responsive" src="./images/image01.png" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="#">
<img class="img-responsive" src="./images/image02.png" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="#">
<img class="img-responsive" src="./images/image03.png" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="#">
<img class="img-responsive" src="./images/image04.png" alt="">
</a>
</div>
</div>
CSS
body {
font-family: 'Baloo Bhaina', cursive;
}
#media (min-width: 1200px)
.container {
width: 1170px;
}
h1 {
text-align: center;
}
.page-header {
background-color: #EFEC86;
padding-top: 20px;
width: 1130px;
}
.top-header {
width: 1130px;
background-color: #EFEC86;
padding-top: 20px;
width: 1290px;
}
.sub {
background-color: #EFEC86;
padding-top: 20px;
}
img {
width: 100%;
height: auto;
display: block;
overflow: auto;
}
.thumbnail {
width: 300px;
height: 300px;
overflow: auto;
max-width:calc(150% - 10px);
margin:0 16px;
}
.thumbnail:hover {
background-color: #EFEC86;
}
.row {
margin-right: 50px;
margin-left: -15px;
}
Why not adding margin when you are hovering each item. Just add margin on the .thumbnail class when it is hovered so that it will not destroy your other item
Related
I am new to css and bootsrap and am trying to use the code from this example:
https://www.bootdey.com/snippets/view/bs4-new-friends-panel
HTML:
<div class="container">
<div class="row">
<div class="col-md-12 col-lg-6">
<div class="card">
<div class="header">
<h2><strong>New</strong> Friends <small>Add new friend in last month</small></h2>
</div>
<div class="body">
<ul class="new_friend_list list-unstyled row">
<li class="col-lg-4 col-md-2 col-sm-6 col-4">
<a href="">
<img src="https://bootdey.com/img/Content/avatar/avatar7.png" class="img-thumbnail" alt="User Image">
<h6 class="users_name">Jackson</h6>
<small class="join_date">Today</small>
</a>
</li>
<li class="col-lg-4 col-md-2 col-sm-6 col-4">
<a href="">
<img src="https://bootdey.com/img/Content/avatar/avatar6.png" class="img-thumbnail" alt="User Image">
<h6 class="users_name">Aubrey</h6>
<small class="join_date">Yesterday</small>
</a>
</li>
<li class="col-lg-4 col-md-2 col-sm-6 col-4">
<a href="">
<img src="https://bootdey.com/img/Content/avatar/avatar5.png" class="img-thumbnail" alt="User Image">
<h6 class="users_name">Oliver</h6>
<small class="join_date">08 Nov</small>
</a>
</li>
<li class="col-lg-4 col-md-2 col-sm-6 col-4">
<a href="">
<img src="https://bootdey.com/img/Content/avatar/avatar3.png" class="img-thumbnail" alt="User Image">
<h6 class="users_name">Isabella</h6>
<small class="join_date">12 Dec</small>
</a>
</li>
<li class="col-lg-4 col-md-2 col-sm-6 col-4">
<a href="">
<img src="https://bootdey.com/img/Content/avatar/avatar2.png" class="img-thumbnail" alt="User Image">
<h6 class="users_name">Jacob</h6>
<small class="join_date">12 Dec</small>
</a>
</li>
<li class="col-lg-4 col-md-2 col-sm-6 col-4">
<a href="">
<img src="https://bootdey.com/img/Content/avatar/avatar1.png" class="img-thumbnail" alt="User Image">
<h6 class="users_name">Matthew</h6>
<small class="join_date">17 Dec</small>
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="col-md-12 col-lg-6">
<div class="card">
<div class="header">
<h2><strong>New</strong> Friends <small>Add new friend in last month</small></h2>
</div>
<div class="body">
<ul class="new_friend_list list-unstyled row">
<li class="col-lg-4 col-md-2 col-sm-6 col-4">
<a href="">
<img src="https://bootdey.com/img/Content/avatar/avatar7.png" class="img-thumbnail" alt="User Image">
<h6 class="users_name">Jackson</h6>
<small class="join_date">Today</small>
</a>
</li>
<li class="col-lg-4 col-md-2 col-sm-6 col-4">
<a href="">
<img src="https://bootdey.com/img/Content/avatar/avatar5.png" class="img-thumbnail" alt="User Image">
<h6 class="users_name">Aubrey</h6>
<small class="join_date">Yesterday</small>
</a>
</li>
<li class="col-lg-4 col-md-2 col-sm-6 col-4">
<a href="">
<img src="https://bootdey.com/img/Content/avatar/avatar1.png" class="img-thumbnail" alt="User Image">
<h6 class="users_name">Oliver</h6>
<small class="join_date">08 Nov</small>
</a>
</li>
<li class="col-lg-4 col-md-2 col-sm-6 col-4">
<a href="">
<img src="https://bootdey.com/img/Content/avatar/avatar3.png" class="img-thumbnail" alt="User Image">
<h6 class="users_name">Isabella</h6>
<small class="join_date">12 Dec</small>
</a>
</li>
<li class="col-lg-4 col-md-2 col-sm-6 col-4">
<a href="">
<img src="https://bootdey.com/img/Content/avatar/avatar6.png" class="img-thumbnail" alt="User Image">
<h6 class="users_name">Jacob</h6>
<small class="join_date">12 Dec</small>
</a>
</li>
<li class="col-lg-4 col-md-2 col-sm-6 col-4">
<a href="">
<img src="https://bootdey.com/img/Content/avatar/avatar2.png" class="img-thumbnail" alt="User Image">
<h6 class="users_name">Matthew</h6>
<small class="join_date">17 Dec</small>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
CSS:
body{
margin-top:20px;
background-color: #f4f6f9;
}
.card {
-moz-transition: all 0.5s;
-o-transition: all 0.5s;
-webkit-transition: all 0.5s;
transition: all 0.5s;
background: #fff;
border-radius: .1875rem;
margin-bottom: 30px;
border: 0;
display: inline-block;
position: relative;
width: 100%;
box-shadow: none;
}
.card .header {
color: #424242;
padding: 20px;
position: relative;
box-shadow: none;
}
.card .header h2 {
color: #757575;
position: relative;
}
.card .header h2:before {
background: #6572b8;
}
.card .header h2 {
font-size: 15px;
}
.card .header h2::before {
position: absolute;
width: 2px;
height: 18px;
left: -20px;
top: 0;
content: '';
}
.theme-purple .card .header h2 strong {
color: #6572b8;
}
.card .header h2 small {
color: #9e9e9e;
line-height: 15px;
}
.card .body {
color: #424242;
font-weight: 400;
padding: 20px;
}
.new_friend_list {
margin-bottom: 0px;
}
.new_friend_list li .users_name {
color: #424242;
text-transform: capitalize;
}
.new_friend_list li .users_name {
margin-top: 5px;
}
.new_friend_list li .users_name{
margin-bottom: 0px;
}
.new_friend_list li .join_date {
color: #757575;
}
a {
outline: none !important;
color: #007bff;
text-decoration: none;
background-color: transparent;
}
I need to update it so that there are 5 data elements in each row instead of 3 as it is now. If anyone could help explain how to do that it would be appreciated!
I have tried column-count and it doesn't seem to work.
Thanks.
This my first answer (excited)
First inspect the html and find the line of code below. Change the col-lg-4 for col-lg-2 on each <li> element.
The modification is for large screen only
Actual:
<li class="col-lg-4 col-md-2 col-sm-6 col-4"> <img src="https://bootdey.com/img/Content/avatar/avatar1.png" class="img-thumbnail" alt="User Image"><h6 class="users_name">Matthew</h6> <small class="join_date">17 Dec</small> </li>
Modified:
<li class="col-lg-2 col-md-2 col-sm-6 col-4"> <img src="https://bootdey.com/img/Content/avatar/avatar1.png" class="img-thumbnail" alt="User Image"><h6 class="users_name">Matthew</h6> <small class="join_date">17 Dec</small> </li>
For more understanding take a look at this page https://getbootstrap.com/docs/5.1/layout/grid/
Tschuss
You should remove class col-lg-4 and replace it with class .w-20
Than in css, add class .w-20 like this:
.w-20 {
-webkit-box-flex: 0;
-ms-flex: 0 0 20%;
flex: 0 0 20%;
max-width: 20%;
}
Original, more detailed answer to the same question you can found here:
https://stackoverflow.com/a/50747942/2719670
I'm work on bootstrap project and I try to put uploading image to set grid view, but uploading image are not same size 4 images are difference size, I put the image width and height but its not working image are sketching and not display full image any one know how to fix that issue
Thanks
,
/*image*/
.thumbnail{
width: 164px;
height: 164px;
overflow: hidden;
margin: auto;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row display-flex">
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="thumbnail">
<img src="https://www.averagejoes.co.uk/averagejoes.co.uk/public_html/wp-content/uploads/2018/06/ihotel-taiwan-hotel-gaming-esports-video-games-1.jpg" alt="" class="avatar">
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="thumbnail">
<img src="https://www.averagejoes.co.uk/averagejoes.co.uk/public_html/wp-content/uploads/2018/06/ihotel-taiwan-hotel-gaming-esports-video-games-1.jpg" alt="" class="avatar">
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="thumbnail">
<img src="https://exp.cdn-hotels.com/hotels/2000000/1900000/1897400/1897350/7180d426_z.jpg" alt="" class="avatar">
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="thumbnail">
<img src="https://www.averagejoes.co.uk/averagejoes.co.uk/public_html/wp-content/uploads/2018/06/ihotel-taiwan-hotel-gaming-esports-video-games-1.jpg" alt="" class="avatar">
</div>
</div>
</div>
Add class img-fluid on image .
Like this
<img src="https://www.averagejoes.co.uk/averagejoes.co.uk/public_html/wp-content/uploads/2018/06/ihotel-taiwan-hotel-gaming-esports-video-games-1.jpg" alt="" class="img-fluid">
or
update the following css :
.thumbnail img {
width: 100%;
height: auto;
}
Add Following Css to the code object-fit: cover; May Help You
.thumbnail
{
width: 164px;
height: 164px;
overflow: hidden;
margin: auto;
}
.thumbnail img {
width: 164px;
height: 100%;
object-fit: cover;
}
To make images fit in the containing div, add the class img-fluid to them. This wil give them a width: 100%; height: auto;.
This won't give them all the same height, as they have different sizes/aspect ratios.
/*image*/
.thumbnail{
width: 164px;
height: 164px;
overflow: hidden;
margin: auto;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row display-flex">
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="thumbnail">
<img src="https://www.averagejoes.co.uk/averagejoes.co.uk/public_html/wp-content/uploads/2018/06/ihotel-taiwan-hotel-gaming-esports-video-games-1.jpg" alt="" class="img-fluid avatar">
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="thumbnail">
<img src="https://www.averagejoes.co.uk/averagejoes.co.uk/public_html/wp-content/uploads/2018/06/ihotel-taiwan-hotel-gaming-esports-video-games-1.jpg" alt="" class="img-fluid avatar">
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="thumbnail">
<img src="https://exp.cdn-hotels.com/hotels/2000000/1900000/1897400/1897350/7180d426_z.jpg" alt="" class="img-fluid avatar">
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<div class="thumbnail">
<img src="https://www.averagejoes.co.uk/averagejoes.co.uk/public_html/wp-content/uploads/2018/06/ihotel-taiwan-hotel-gaming-esports-video-games-1.jpg" alt="" class="img-fluid avatar">
</div>
</div>
</div>
In the next image you can see what I want to achieve:
Desktop
Mobile
How can I do this?
I've been trying something like this:
<div class="row">
<div class="col-md-10">
<div class="row">
<div class="col-md-10" style="overflow:auto;">
<h1>Profile</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer id ligula tincidunt eros eleifend porttitor. Maecenas cursus volutpat erat.
</p>
</div>
<!--feeds-->
<div class="col-md-2">
<h3>-- Feeds --</h3>
</div>
</div>
</div>
<!--fixed menu-->
<div class="col-md-2" style="background-color:#2ecc71;padding:3px;">
<div class="text-center">
<img src="/img/1.png" class="img-circle" style="max-width:150px">
<h3>hi!</h3>
</div>
<div>
<!-- menu links -->
</div>
</div>
</div>
Thanks in advance.
I believe this is what you're trying to do. You could use the default Bootstrap navbar by changing it's position rules (position: fixed;) to suit your needs while inside of a media query so once you're below 768px your nav adjusts to the default toggle nav. See Navbar for reference.
Working Example: Open at full page and reduce the viewport.
html,
body {
height: 100%;
}
#media (max-width: 767px) {
body {
padding-top: 50px;
}
}
#media (min-width: 768px) {
.navbar.sidebar-nav {
position: fixed;
top: 0;
bottom: 0;
right: 0;
left: auto;
height: 100%;
width: 200px;
background: #222;
overflow-y: auto;
}
.navbar.sidebar-nav .navbar-header {
width: 100%;
}
.navbar.sidebar-nav .navbar-header .navbar-brand {
float: right;
}
.navbar.sidebar-nav .navbar-nav {
width: 100%;
height: 100%;
text-align: right;
}
.navbar.sidebar-nav .navbar-nav > li {
float: none;
display: block;
}
.main-content {
margin-right: 200px;
}
}
/*THUMBNAIL FOR DEMO ONLY*/
.thumbnail {
border: none;
border-radius: 0px;
background: rgba(255, 255, 255, 0.75);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10), 0 1px 2px rgba(0, 0, 0, 0.20);
padding: 25px;
max-width: 500px;
margin: 12.5px auto;
}
/*THUMBNAIL FOR DEMO ONLY*/
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-inverse navbar-fixed-top sidebar-nav">
<div class="container-fluid">
<div class="navbar-header">
<button data-toggle="collapse" type="button" class="navbar-toggle collapsed" data-target="#bs-nav">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Navbar Brand</a>
</div>
<div class="navbar-collapse collapse" id="bs-nav">
<ul class="nav navbar-nav">
<li>Link One
</li>
<li>Link Two
</li>
<li>Link Three
</li>
<li>Link Four
</li>
<li>Link Five
</li>
</ul>
</div>
</div>
</nav>
<div class="main-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/000/000" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/000/000" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/000/000" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/000/000" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/000/000" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/000/000" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/000/000" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/000/000" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/000/000" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/000/000" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/000/000" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/000/000" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="thumbnail">
<img src="http://placehold.it/450x450/f00/f00" class="img-responsive" />
</div>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
Stupid question: I have three images in a row, but they are aligned to the left in their column. How can I align them to the center of the column?
This is my code:
<div class="container partners">
<div class="row">
<div class="col-md-4 col-sm-4 col-xs-4">
<img src="swz.png" alt="streetwize" class="img-circle" class="img-responsive" style="max-height:180px">
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
<img src="ogon.png" alt="ogon" class="img-circle" class="img-responsive" style="max-height:180px">
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
<img src="congaz.png" alt="ogon" class="img-circle" class="img-responsive" style="max-height:180px">
</div>
</div>
And CSS:
.partners {
display:block;
margin: 0 auto;
vertical-align:middle;
}
Add the text-center class to your column divs
<div class="col-md-4 col-sm-4 col-xs-4 text-center">
First of all you can not write 2 class tag on same element
<img src="swz.png" alt="streetwize" class="img-circle" class="img-responsive" style="max-height:180px">
instead of this you can write class="img-circle img-responsive"
for center aligning u can use "text-center" class to parent div..
or you can also apply style="float:none; margin:0 auto;" to img.
thanks, hope this will help you.
The idea is to make image block element and margin of auto. but as the margin:auto won't work except you assign some width of the elemet.
.partners img{
display: block;
margin: auto;
text-align: center;
width: 150px;
}
.partners {
display:block;
margin: 0 auto;
vertical-align:middle;
}
.partners img{
display: block;
margin: auto;
text-align: center;
width: 150px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container partners">
<div class="row">
<div class="col-md-4 col-sm-4 col-xs-4">
<img src="swz.png" alt="streetwize" class="img-circle" class="img-responsive" style="max-height:180px">
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
<img src="ogon.png" alt="ogon" class="img-circle" class="img-responsive" style="max-height:180px">
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
<img src="congaz.png" alt="ogon" class="img-circle" class="img-responsive" style="max-height:180px">
</div>
</div>
<div class="text-center">
<img src="swz.png" alt="streetwize" class="img-circle" class="img-responsive" style="max-height:180px">
</div>
it would work defiantly.
I am having a problem with bootstrap 3 and some thumbnails where although I'm using the same code and the image sizes are exactly the same the last image row is broken on mobile when in vertical only
Here is the code:
<div class="container">
<div class="row">
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="?service=4">
<img class="img-responsive" src="http://mysite/tn-1_256x300.jpg" alt="">
<div class="text-center text_margin">styling</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="?service=5">
<img class="img-responsive" src="http://mysite/tn-2_256x300.jpg" alt="">
<div class="text-center text_margin">colour</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="?service=6">
<img class="img-responsive" src="http://mysite/tn-3_256x300.jpg" alt="">
<div class="text-center text_margin">extensions</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="?service=7">
<img class="img-responsive" src="http://mysite/tn-4_256x300.jpg" alt="">
<div class="text-center text_margin">hair enhancements</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="?service=8">
<img class="img-responsive" src="http://mysite/tn-5_256x300.jpg" alt="">
<div class="text-center text_margin">smoothing treatment</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="?service=9">
<img class="img-responsive" src="http://mysite/tn-6_256x300.jpg" alt="">
<div class="text-center text_margin">hair up</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="meet-the-team">
<img class="img-responsive" src="http://mysite/tn-7_256x300.jpg" alt="">
<div class="text-center text_margin">meet the team</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="/price-list/">
<img class="img-responsive" src="http://mysite/tn-8_256x300.jpg" alt="">
<div class="text-center text_margin">price list</div>
</a>
</div>
</div><!--end row-->
</div><!--end container-->
This is happening because some of the text below the thumbnails is wrapping, and as a result the thumbnail heights are different. One way to fix this problem is to clear the columns float on mobile with CSS like this..
#media (max-width: 768px) {
.row > .col-xs-6:nth-child(2n+1) {
clear: left;
}
}
Demo 1: http://codeply.com/go/Bgt8JFkPht
Another option (simpler), is to use CSS text-overflow ellipsis on the text DIV's since it's these DIVs that are causing the height to be different on each thumbnail. When the thumbnail heights are the same, the row wrapping is not an issue..
Demo 2: http://codeply.com/go/5uOP4bM5pk
Check your text-margin class, when adding a margin or padding to some items in Bootstrap, you change the width of your columns.