i have a problem creating three four columns div inside the bootstrap thumbnail. The problem is that if i use the col-xs-4 class, the text inside go out of the caption of bootstrap. And if i use three div inside another one, it works, but i can't align the text inside each div at the center. Any ideas? Currently i use this script:
<div class="col-md-3 col-lg-3 col-xs-6 col-sm-4">
<a href="profilo?id=<?php echo $dati['id'];?>" class="thumbnail">
<img src="<?php echo $url1;?>" alt="Immagine profilo" />
<span class="flag-diamond"></span>
<div class="caption">
<div class="esc_username"><span class="username"><?php echo $username;?></span><span class="hidden-xs age"><?php echo $anni;?> anni</span></div>
<div class="esc_city"><?php echo $dati['citta'];?></div>
<div style="width:100%">
<div class="col-xs-4">TRY</div>
<div class="col-xs-4">TRY</div>
<div class="col-xs-4">TRY</div>
</div>
</div>
</a>
</div>
and i get this:
but i want to do something like this:
[EDIT]
If i add padding:0 to the three div, i get this:
With Bootstrap you can nest divs which basically means that you can just add a surrounding row to your 3 divs.
<div class="row">
<div class="col-xs-4">TRY</div>
<div class="col-xs-4">TRY</div>
<div class="col-xs-4">TRY</div>
</div>
The reason this should work is because row class has negative left and right margins which will automatically adjust itself to the container which, in your case, is the outer div.
write class
.no-padding{
padding:0px;
}
Then apply where you don't want padding as follows
<div class="col-xs-4 no-padding">TRY</div>
<div class="col-xs-4 no-padding">TRY</div>
<div class="col-xs-4 no-padding">TRY</div>
I hope this will solve your problem if not try adding !important to padding this will override other padding if it's overriding
.no-padding{
padding:0px !important;
}
please try this css code instead of col-xs-4:
<div class="col-sm-4">TRY</div>
<div class="col-sm-4">TRY</div>
<div class="col-sm-4">TRY</div>
best way you can set the padding = 0 or you can set a background-color for the container div
like
<div class="col-md-3 col-lg-3 col-xs-6 col-sm-4">
<a href="profilo?id=<?php echo $dati['id'];?>" class="thumbnail">
<img src="<?php echo $url1;?>" alt="Immagine profilo" />
<span class="flag-diamond"></span>
<div class="caption">
<div class="esc_username"><span class="username"><?php echo $username;?></span><span class="hidden-xs age"><?php echo $anni;?> anni</span></div>
<div class="esc_city"><?php echo $dati['citta'];?></div>
<div style="width:100%;background-color:#EEE;">
<div class="col-xs-4">TRY</div>
<div class="col-xs-4">TRY</div>
<div class="col-xs-4">TRY</div>
</div>
</div>
</a>
</div>
Related
I wanted three images in each row...
<div class="row">
<div class="col-lg-4">
<div class="thumbnail">
<img src="https://images.pexels.com/photos/1714208/pexels-photo-1714208.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500">
</div>
</div>
<div class="col-lg-4">
<div class="thumbnail">
<img src="https://images.pexels.com/photos/2103864/pexels-photo-2103864.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500">
</div>
</div>
<div class="col-lg-4">
<div class="thumbnail">
<img src="https://images.pexels.com/photos/1476321/pexels-photo-1476321.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500">
</div>
</div>
I expected it to be inside the border and all the images should have been of same size (three in each row) ...But its not.. help...
You have <div class="thumbnail">, but the built-in bootstrap 3 thumbnail classname is <div class="img-thumbnail">.
You say you want all images to be the same size, but your images have different proportions. Their pixel sizes are: 500x333, 500x750, and 500x375. What behavior do you want exactly? You could force them to all be the same height and width by setting adding styles for height=500px; width=500px;, but then the images will be distorted and squashed.
What you'll want to do is remove &w=500 from the image URLs so they scale to the dynamic width of the Bootstrap grid, and maybe also change the class on the columns to col-md-4 or col-sm-4 to make sure the images sit next to each other on smaller screens.
<div class="row">
<div class="col-md-4">
<div class="thumbnail">
<img src="https://images.pexels.com/photos/1714208/pexels-photo-1714208.jpeg?auto=compress&cs=tinysrgb&dpr=1">
</div>
</div>
<div class="col-md-4">
<div class="thumbnail">
<img src="https://images.pexels.com/photos/2103864/pexels-photo-2103864.jpeg?auto=compress&cs=tinysrgb&dpr=1">
</div>
</div>
<div class="col-md-4">
<div class="thumbnail">
<img src="https://images.pexels.com/photos/1476321/pexels-photo-1476321.jpeg?auto=compress&cs=tinysrgb&dpr=1">
</div>
</div>
</div>
If you want all three images to have the same height as well, you could do something like this:
.thumbnail img {
max-height: 300px;
}
To achieve true dynamic uniformity, you should look at using Bootstrap 4 card groups instead.
I am facing a problem with the Bootstrap-4 grid system. There are 12 columns, and whenever I use less than 12 columns, the rows are automatically centered. I want left alignment, how can this be fixed?
A snippet of my code:
<div class="row justify-content-start con-flex">
<?php foreach($books as $book):?>
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6">
<div id="single-book">
<div id="book-image">
<?php print '<img src = "'.strip_tags($book->book_image).'" alt = "">';?>
<div id="addto-cart"><i class="fas fa-shopping-cart"></i> Add to cart</div>
</div>
<div class="book-text">
<div id="book-name"><?= substr(htmlentities($book->book_name),0,21) ?></div>
<div id="author">By <i><?= htmlentities($book->author) ?></i></div>
<div id="price"><?= htmlentities($book->price) ?>.TK</div>
<div id="book-details">
<?php print 'View details'; ?>
</div>
</div>
</div>
</div>
<?php endforeach;?>
</div>
image of code:
enter image description here
According to Bootstrap doc that should solve your problem
<div class="container">
<div class="row justify-content-start">
<div class="col-4">
content here...
</div>
<div class="col-4">
content here...
</div>
</div>
</div>
The code you have should be working fine, columns will be aligned left by default; maybe what you are seeing is the result of using .container instead of .container-fluid which uses the full width of the viewport. It's either this or you might have some custom CSS that's affecting the layout of the columns
<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-4 col-md-4 border">content here...</div>
<div class="col-4 col-md-4 border">content here...</div>
</div>
</div>
<div class="container-fluid">
<div class="row ">
<div class="col-4 col-md-4 border">content here...</div>
<div class="col-4 col-md-4 border">content here...</div>
</div>
</div>
This problem was for my other base CSS.
Instead of:
*{
margin: 0 auto;
}
For this margin: 0 auto; in my main style.css file My bootstrap's grids were not working properly. Now I remove this margin: 0 auto from *.
Now
I write
* {
margin: 0;
padding: 0;
}
Now my bootstrap grids are working properly
I want my date picker to be in the middle of the page, eg. the line where I have: <div class="center-block text-center datepicker"></div>
Obviously center-block and text-center I tried already - but neither change anything. And with the offset it just makes it close to the centre without being perfectly centre aligned.
What do I need to do?
Thanks
<div class='row'>
<div class='col-sm-12'>
<div class='page-header page-header-with-icon mg-t'> <i class='fa-icon-calendar'></i>
<h2>Calendar</h2>
</div>
<div class="row">
<div class="col-sm-4 col-sm-offset-4">
<div class="center-block text-center datepicker"></div>
</div>
</div>
</div>
</div>
Try something like this:
<div class="col-sm-12">
<div class="datepicker"></div>
</div>
Then give the date picker something like:
.datepicker {
display:inline-block;
margin:0 auto;
}
I haven't tested this, but it would be where I would start.
style="text-align:center;" shall do the trick no? I tested and for me, the "CALENDAR" text is centered
<div class="col-sm-12">
<div class="page-header page-header-with-icon mg-t" style="text-align:center;">
<i class="fa-icon-calendar"></i>
<h2>Calendar</h2>
</div>
<div class="row">
<div class="col-sm-4 col-sm-offset-4">
<div class="center-block text-center datepicker"></div>
</div>
</div>
</div>
</div>
This is what should solve your problem. Add it somewhere in your custom stylesheet and change the width % to what suits your design.
.datepicker-inline {
width: 20%;
}
I'm using a template with Bootstrap.
The following code:
<div class="row mix-grid thumbnails wrapper white" id="pictures_placeholder">
<div class="col-md-3 col-sm-4 mix ">
<div class="mix-inner">
<img class="img-responsive" src="../../../assets/admin/pages/media/works/img1.jpg"
alt="">
<div class="mix-details picture-bottom-label">
<div class="row">
<div class="col-md-12 col-xs-12">
<div class="col-md-4 col-xs-3">
<img src="../../../assets/admin/pages/media/profile/profile_user.jpg"
class="img-responsive img-circle profile-pic"
alt=""
/>
</div>
<div class="col-md-8 col-xs-8 text-left user-name">Asaf Nevo</div>
</div>
</div>
</div>
</div>
</div>
</div>
does this:
How can I make the name (Asaf Nevo) to be entered to the image ?
try adding this to CSS:
div.user-name{height:92px;line-height:92px;}
hope that helps.
Put the name in the same div as the image. Make both inline.
<img src="../../../assets/admin/pages/media/profile/profile_user.jpg"
class="img-responsive img-circle profile-pic" alt="" />Asav Nevo
Now play with the CSS property vertical-align. Something like vertical-align: middle could work and yes, this property should be applied to the surrounding div if not mistaken, potentially also to the inline content itself. I cannot try it right now.
Add this to the css:
.user-name {
margin-top:50%;
}
I'd have two "sections" in which I am using the bootstrap 3 scaffolding to style. I am having a hard time figuring out how I might have these maintain their column spacing while still be centered on the middle of the page. For example right now it is
<content><content> ---<space>---
and i want
---<space>--- <content><content> ---<space>---
Here is what i've got.
<div class=".container-fluid" id="aboutContent">
<div class="col-md-3">
<img src="../imgs/pic.jpg" alt="Joe Brunett" id="aboutPicture"/>
</div>
<div class="well col-md-4" id="desc">
<p> text<p>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3"></div>
</div>
</div>
Offsets can be used to center a div but remember that it'll work only for even columns
<div class="col-md-8 col-md-offset-2"></div>
You can even change the break-point by replacing
<div class="col-md-6 col-md-offset-3"></div>
with
<div class="col-sm-6 col-sm-offset-3"></div>