Structuring thumbnails on bootstrap - html

So I have this issue with positioning and aligning thumbnails. I want to put fixed width and height on a div but as I am using Bootstrap, I've put col-md and col-xs for responsiveness, and now I can't figure out how to fit every image no matter how big it is to be a fixed width and height. Ive tried percentage and px, but then it loses its mobility and responsiveness and stays fixed on that width. Here is a picture of the problem http://postimg.org/image/n4tnblczd/ . I would be very thankfull on some advice how to resize big pictures to fixed width and heights but to remain it's responsiveness.

Before asking question suggest as giving your sample code. I think you want to know the process of html structure.
Use below html code for bootstrap support. col-md and col-sm in div class. img class will be "img-responsive" . It will get bootstrap.min.css
<div class="col-md-6 col-sm-6 col-xs-12 text-left">
<img src="/images/choose-us.png" class="img-responsive">
</div>
Use this I think it will solve your problem.here is screenshot I applied using my css with different image size.
Below snippet code not displaying exact style because of bootstrap css link.
.thumbnail{
padding: 0px;
border-radius: 0px;
position: relative;
border: 1px solid #222;
}
.thumbnail img{
height: 347px;
}
.drzac{
margin-top: 30px;
}
.overlay{
display: block;
transition: all 0.3s;
-webkit-transition: all 0.3s;
background-color: rgba(50, 200, 235, 0.5);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
font-size: 2em;
text-align: center;
}
<div class="col-xs-6 col-md-4">
<div class="thumbnail">
<img src="http://www.it4gen.com/wp-content/uploads/2013/02/learnindoorgrowing.com_-460x345.png" class="img-responsive">
<div class="centered"><i class="fa fa-search"></i></div>
</div>
</div>
<div class="col-xs-6 col-md-4">
<div class="thumbnail">
<img src="http://www.totalcableusa.com/images/choose-us.png">
<div class="centered"><i class="fa fa-search"></i></div>
</div>
</div>
<div class="col-xs-6 col-md-4">
<div class="thumbnail">
<img src="http://www.totalcableusa.com/images/choose-us.png">
<div class="centered"><i class="fa fa-search"></i></div>
</div>
</div>

Related

Fill width of a div containing a horizontal array of images with css

I have a container div with multiple varying-width, uniform-height images. The images are horizontally arranged with no gaps between them.
What I have so far:
#imageContainer {
width: 80%;
border: 1px solid blue;
position: relative;
left: 50%;
transform: translateX(-50%);
}
#images {
display: flex;
width: 80%;
position: relative !important;
margin: 2px;
}
#imageContainer img {
display: inline-block;
position: relative;
margin: 1px;
}
<div id="imageContainer">
<div id="images">
<img src="https://dummyimage.com/400x100/000/fff" alt="">
<img src="https://dummyimage.com/320x100/000/fff" alt="">
<img src="https://dummyimage.com/420x100/000/fff" alt="">
<img src="https://dummyimage.com/540x100/000/fff" alt="">
</div>
</div>
I would like for all of the images to scale to fit within my div, filling it, but I can't seem to find where I can do this with multiple images.
I question is basically this one but with a twist of also scaling to fit.
Unless you want a gap in your box you should remove width/position from the inner #images container. To make the images scale down you can add a min-width. If you want the images to not distort add an object-fit:
#imageContainer {
width: 80%;
border: 1px solid blue;
position: relative;
left: 50%;
transform: translateX(-50%);
}
#images {
display: flex;
margin: 2px;
}
#imageContainer img {
display: inline-block;
position: relative;
margin: 1px;
/* Important bits: */
min-width: 0;
object-fit: contain;
}
<div id="imageContainer">
<div id="images">
<img src="https://dummyimage.com/400x100/000/fff" alt="">
<img src="https://dummyimage.com/320x100/000/fff" alt="">
<img src="https://dummyimage.com/420x100/000/fff" alt="">
<img src="https://dummyimage.com/540x100/000/fff" alt="">
</div>
</div>
(Btw, centering using left + transform can cause blurriness in some rendering engines.)
I prefer using Bootstrap for most of my front-end styling as they provide lots of nifty "features" that make it easy for me to create a nice looking front-end without having to spend hours with CSS trying to get it looking perfect or making it scalable to multiple viewports.
Hence, here is how I would solve it using Bootstrap-4. (Here is a Codepen link)
<div class="container">
<div class="row outline-primary">
<div class="col">
<img src="https://dummyimage.com/400x100/000/fff" class="img-fluid h-100">
</div>
<div class="col">
<img src="https://dummyimage.com/320x100/000/fff" class="img-fluid h-100">
</div>
<div class="col">
<img src="https://dummyimage.com/420x100/000/fff" class="img-fluid h-100">
</div>
<div class="col">
<img src="https://dummyimage.com/540x100/000/fff" class="img-fluid h-100">
</div>
</div>
</div>

Div align to center

Hello i spent hours doing this but still can't align the social media icons to the center of text "Connect with us" when it's in desktop size. It's only aligned when it's in mobile size i want them to align to center either its desktop size or mobile. I want the content of the footer to be responsive. I already used media queries but i encounter a problem so i repeat my footer again from the start because its not responsive when in desktop size. Please give me some ideas how to do it or suggestions. Im new to html and css.
here is the desktop size. I want the social media icons to align to the center of text "Connect with us".
here is the mobile size. Its well aligned here.
UPDATE:
This is what i want to do in the first picture. But i repeat my footer because when i minimized it as a desktop its not responsive the alignments, the text, the height it's a disaster so i decided to do it again from the start. I already used media queries before but as a desktop its not working when i minimized it it's not responsive but in mobile size its working.
here is my html code for the footer.
<div class="content">
</div>
<footer class="footer">
<div class="container">
<div class="row">
<div class="footer-col col-sm-4">
<h4 class="connect">Connect With Us</h4>
<div class="twitter-hover social-slide"></div>
<div class="facebook-hover social-slide"></div>
<div class="linkedin-hover social-slide"></div>
</div>
</div>
</div>
</div>
</footer>
here is my css code.
* {
margin: 0;
}
html, body {
height: 100%;
overflow: auto;
}
.content {
min-height: 100%;
/* equal to footer height */
margin-bottom: auto;
}
.content:after {
content: "";
display: block;
}
.footer, .content:after {
height: auto;
}
.footer {
display: block;
background-color: #a92419;
color:#fff;
font-family: Century Gothic;
width: 100%;
height: auto;
}
h4{
text-align: center;
padding-top: 20px;
}
.twitter-hover {
background-image: url('images/twitter-hover.png');
margin-left: 65px;
}
.facebook-hover {
background-image: url('images/facebook-hover.png');
margin-left: 15px;
}
.linkedin-hover {
background-image: url('images/linkedin-hover.png');
margin-left: 15px;
}
.social-slide:hover {
background-position: 0px -48px;
box-shadow: 0px 0px 4px 1px rgba(0,0,0,0.8);
}
.social-slide{
height: 35px;
width: 38px;
float:left;
-webkit-transition: all ease 0.3s;
-moz-transition: all ease 0.3s;
-o-transition: all ease 0.3s;
-ms-transition: all ease 0.3s;
transition: all ease 0.3s;
}
Update: rewritten my answer completely.
You shouldn't use float:left when you want your content to be centered.
<div class="footer-col col-sm-4">
<h4 class="connect">Connect With Us</h4>
<ul>
<li><span class="twitter-hover social-slide"></span></li>
<li><span class="facebook-hover social-slide"></span></li>
<li><span class="linkedin-hover social-slide"></span></li>
</ul>
</div>
css:
.footer-col h4 {
text-align: center;
}
.footer-col ul {
list-style: none;
text-align: center;
}
.footer-col li {
display: inline;
}
.social-slide {
display: inline-block;
height: 35px;
width: 38px;
line-height: 35px;
margin-left: 15px;
/* don't use float: left! */
}
.social-slide:first-child {
margin-left: 0;
}
.twitter-hover { background-image: url('images/twitter-hover.png'); }
.facebook-hover { background-image: url('images/facebook-hover.png'); }
.linkedin-hover { background-image: url('images/linkedin-hover.png'); }
if you also use bootstrap latest then you use this class
col-sm-offset-......12
you don't know what size of your device you adjust self` col-sm-offset........12345 up to12
for more detail read out
https://getbootstrap.com/examples/grid/
Here is the fiddle
https://jsfiddle.net/brunocoder/ozgntcm2/1/
First of all there is one extra closing div in your footer tag.
You need to use bootstrap offset property to centralize your column. Here is the link http://getbootstrap.com/css/#grid
So your code should be something like this.
Modified HTML
<div class="content">
</div>
<footer class="footer">
<div class="container">
<div class="row">
<div class="footer-col col-sm-4 col-md-4 col-lg-4 col-md-offset-4">
<h4 class="connect">Connect With Us</h4>
<div class="twitter-hover social-slide"></div>
<div class="facebook-hover social-slide"></div>
<div class="linkedin-hover social-slide"></div>
</div>
</div>
</div>
</footer>
Use bootstrap in every section of your code, like if you have used div inside the div , use bootstrap to align them also as if you not then it will not align themselves according to the screen size.
<footer class="footer">
<div class="container">
<div class="row">
<div class="footer-col col-sm-4 col-md-4 col-lg-4 col-md-offset-4">
<h4 class="connect">Connect With Us</h4>
<a href="https://twitter.com/official_gapc" target="_blank" title="Follow us on Twitter">
<div class="twitter-hover social-slide col-sm-4">
</div>
</a>
<a href="https://www.facebook.com/pages/Governor-Andres-Pascual-CollegeNavotas-City/344134628983014?fref=ts" target="_blank" title="Like us on Facebook">
<div class="facebook-hover social-slide col-sm-4">
</div>
</a>
<a href="https://www.linkedin.com/edu/governor-andres-pascual-college-in-navotas-city-39345" target="_blank" title="Join us on Linkedin">
<div class="linkedin-hover social-slide col-sm-4">
</div>
</a>
</div>
<div class="footer-col col-sm-4 col-md-4 col-lg-4 col-md-offset-4"></div>
<div class="footer-col col-sm-4 col-md-4 col-lg-4 col-md-offset-4"></div>
</div>
</div>
</footer>
place anything you want to place in two div below or remain as it is, might it will help you to make responsive footer.

Boostrap: How to "stick" a button over an image when re-sizing

I have an image in which I need to put a button over, the problem is that I don't know how to place the button and automatically re-size and position it when making the browser smaller, right now I have the button in place, but when I re-size the browser to get smaller the button moves, I tried using percentages in the css buy doesn't work, what can I do?
<div id="discover" class="container-fluid">
<div class="row-fluid">
<div class="col-lg-12 col-sm-12 col-xs-12 col-md-12 withimg">
<img id="discoveryour" src="img/x.png" class="img-responsive">
</div>
</div>
<div class="row-fluid">
<div id="bttnimg" class="col-lg-12 col-sm-12 col-xs-12 col-md-12">
<form id="start" method="post" action="x.php">
<button class="btn-primary">text</button>
</form>
</div>
</div>
</div>
Css:
.withimg {
width: 100%;
overflow:hidden;
padding: 0px;
margin: 0px;
}
#discover{
position: relative;
}
#bttnimg{
float: left;
position: absolute;
left: 62%;
top: 25%;
max-width: 750px;
}
Ah, the good old "how to overlay stuff on top of a responsive image -- responsively" question.
A little tricky, but not too bad. The tricky bit is how to make the stuff's vertical position responsive when the image size changes.
Fear not, here's one simple way to do this:
HTML:
<div class="img-wrapper">
<img class="img-responsive"
src="http://lorempixel.com/output/people-q-c-1200-400-4.jpg">
<div class="img-overlay">
<button class="btn btn-md btn-success">Button</button>
</div>
</div>
CSS:
.img-wrapper {
position: relative;
}
.img-responsive {
width: 100%;
height: auto;
}
.img-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
text-align: center;
}
.img-overlay:before {
content: ' ';
display: block;
/* adjust 'height' to position overlay content vertically */
height: 50%;
}
The img-overlay:before pseudo-class handles the vertical positioning job by pushing the img-overlay div down from the top of the image. In this example, the top of the button will always be 50% down the image (change the height: 50% attribute if you want the button higher or lower).
jsfiddle
To make the button size responsive to window width, you can create a new class for your button. Let's call it btn-responsive (this replaces btn-md in the example above). Then use #media queries to adjust the btn-responsive attributes for different window widths. Something like this:
.btn-responsive {
/* matches 'btn-md' */
padding: 10px 16px;
font-size: 18px;
line-height: 1.3333333;
border-radius: 6px;
}
#media (max-width:760px) {
/* matches 'btn-xs' */
.btn-responsive {
padding: 1px 5px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
}
}
and so forth for other screen widths.
In case you're wondering how to do this with bootstrap 5 (like me), there are new classes that do the trick. For instance, I did this to put a button floating right top over the image (I also use font-awesome but you can use any text/icon you like for the button):
<div class="card">
<img class="card-img-top img-thumbnail" src="someimage.png" alt="alt text">
<div class="card-img-overlay">
<a href="#" class="btn btn-outline-warning btn-sm float-end"
data-bs-toggle="popover" data-bs-content="Edit image" data-bs-trigger="hover focus">
<i class="far fa-edit"></i>
</a>
</div>
<div class="card-body">
<h5 class="card-title">Some title</h5>
<p class="card-text">Some text</p>
</div>
</div>
Check out the official bootstrap documentation for more info.
I have to ask if there's a possibility to replace form tag into another DIV? Then you can just use position: absolute for button. I created fiddle to show how https://jsfiddle.net/1x1pjwk7/

Cutting the top part of an image with overflow or clip

I am trying to cut the top part of an image using css. But using overflow:hidden it automatically starts hiding it from the bottom to top, while I want to keep the bottom part but cut off the top. I see there are only x and y options for overflow.
So I tried it using clip, but this can only be applied when the position is set to absolute or fixed, which breaks my responsiveness (and site overall).
This is how one image looks:
And this is how I want it to look:
This is my html markup of one product tile:
<div class="col-md-3 col-lg-3 mb-80 mb-xs-40">
<div class="post-prev-img">
<a href="listing/product"><img src="cms/images/website/producten/categorien/product.jpg" alt="">
</a>
</div>
<div class="post-prev-title font-alt align-center">
product
</div>
<div class="post-prev-text align-center"></div>
<div class="post-prev-more align-center">
<i class="fa fa-info-circle"></i> Bekijk categorie
</div>
</div>
Is there an easy way to achieve this? I am not looking for big javascript methods, it would be great if this could be done with a couple of lines of css.
.post-prev-imgbefore img {
border: solid 1px red; /* TO SEE RESULT... */
}
.post-prev-img {
overflow: hidden;
}
.post-prev-img img {
border: solid 1px red; /* TO SEE RESULT... */
}
.post-prev-img a {
height: 120px; /* Your height... */
position: relative;
overflow: hidden;
display: block;
}
.post-prev-img a img {
position: absolute;
bottom: 0;
}
<h1>BEFORE:</h1>
<div class="col-md-3 col-lg-3 mb-80 mb-xs-40">
<div class="post-prev-imgbefore">
<a href="listing/product"><img src="https://embed.gyazo.com/eb965662ca8fabb1de523e61c16cfe83.png" alt="">
</a>
</div>
<div class="post-prev-title font-alt align-center">
product
</div>
<div class="post-prev-text align-center"></div>
<div class="post-prev-more align-center">
<i class="fa fa-info-circle"></i> Bekijk categorie
</div>
</div>
<h1>AFTER:</h1>
<div class="col-md-3 col-lg-3 mb-80 mb-xs-40">
<div class="post-prev-img">
<a href="listing/product"><img src="https://embed.gyazo.com/eb965662ca8fabb1de523e61c16cfe83.png" alt="">
</a>
</div>
<div class="post-prev-title font-alt align-center">
product
</div>
<div class="post-prev-text align-center"></div>
<div class="post-prev-more align-center">
<i class="fa fa-info-circle"></i> Bekijk categorie
</div>
</div>
you can still use overflow: hidden , make the image, position: absolute and set bottom: 0, this way the top will overflow but will be hidden. remember for absolute the parent should be position: relative.
so
.image_container {
overflow: hidden;
position: relative;
}
.image {
bottom: 0;
positon: relative
}
You could try another approach
Firstly you set a div with a defined measures and a
.myDiv{
width:50%;
height:300px;
background-image:url('url_here');
}
And this way you can play with the background properties as background-size. I am not sure if this could solve your problem but in my opinion is the easiest way to work with images.
What about transform the image inside the overflow:hidden-container, bro/sis? :)
.post-prev-img {
height: 250px;
overflow: hidden;
}
.post-prev-img img {
transform: translateY(-40px)
}
Bootply-link (you should use that, too)

Center Div on-top and in between two divs in Foundation Zurb

I just started using Foundation and I like it a lot. I have a question. I have a design that requires the logo to be horizontally centered, on-top and in between two full divs (see attached picture).
The code below is what I have which seems to work fine but doesn't re-size on screen changes and I was wondering if there was a better way to accomplish this when working with Foundation.
Is there a possible improvement that I could do to better integrate the logo into Foundation? In other words is there a way to integrate the logo in a way that It re-sizes when the screen changes or this is my best option and I would need to re-size it manually for multiple screens?
HTML
<div class="row fullWidth">
<div class="large-12 columns box">
<img src="logo.png" class="logo">
</div>
</div>
<div class="row fullWidth">
<div class="large-12 columns box"> </div>
</div>
CSS
.fullWidth {
width: 100%;
margin-left: auto;
margin-right: auto;
max-width: initial;
position: relative;
}
.logo{
position:absolute;
left: 50%;
top: 20px;
margin-left: -100px;// half-width of logo
z-index: 20;
}
.box{
background-color: #333;
height: 120px;
margin-bottom: 10px;
}
If you know the height of the logo, you can use negative margin-top as well, but you'll probably have to wrap the 2 outer divs with a new div.
HTML:
<div class="outer">
<div class="row fullWidth">
<div class="large-12 columns box">
<img src="logo.png" class="logo">
</div>
</div>
<div class="row fullWidth">
<div class="large-12 columns box"> </div>
</div>
</div>
CSS:
.outer {
width: 100%;
position:relative;
}
.fullWidth {
width: 100%;
margin-left: auto;
margin-right: auto;
max-width: initial;
// position: relative; // REMOVED
}
.logo{
position:absolute;
left: 50%;
top: 50%;
margin-left: -100px;// half-width of logo
margin-top: -100px;// half-height of logo
z-index: 20;
}
You can do the following to make it center
<div class="row fullWidth">
<div class="large-12 columns box">
<img src="logo.png" class="logo">
</div>
<div class="row fullWidth">
<div class="large-12 columns box"> </div>
</div>
</div>
DEMO
Is it the logo that doesn't resize? If so, try this:
.logo{
position:absolute;
left: 50%;
top: 20%;
margin-left: -100px;//half-width of logo
z-index: 20;
}
The logo should be able to resize now.