Skip to content

Instantly share code, notes, and snippets.

@petehouston
Created October 17, 2014 07:20
Show Gist options
  • Save petehouston/85dd33210c0764eeae55 to your computer and use it in GitHub Desktop.
Save petehouston/85dd33210c0764eeae55 to your computer and use it in GitHub Desktop.
[Bootstrap] Text overlay center inside the image
<div class="row" id="box-search">
<div class="thumbnail text-center">
<img src="img/cafe.jpg" alt="" class="img-responsive">
<div class="caption">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab, quisquam?</p>
</div>
</div>
</div>
.thumbnail {
position: relative;
}
.caption {
position: absolute;
top: 45%;
left: 0;
width: 100%;
}
@VanessaNoble
Copy link

Thanks a million...very helpful

@Ludovicmoreau
Copy link

thank you !

@NikkoDomingo
Copy link

deal
How can i do this kind of ovelay text thanks

@desiba
Copy link

desiba commented Feb 8, 2017

thank you

@xabispacebiker
Copy link

This is so nice, thank you !

@Fefein
Copy link

Fefein commented May 23, 2017

Thanks a lot

@monishRahane05
Copy link

Awesome

@sandy02
Copy link

sandy02 commented Jun 7, 2017

Thank you !!

@willardshikami
Copy link

Thanks alot!!

@KonanFrancko
Copy link

good morning you saved my day too thank you!

@hermanaguirrej
Copy link

Thank you very much!

@jmubago
Copy link

jmubago commented Apr 2, 2018

Very helpful mate!

@platadani
Copy link

Thank you!

@mrtnuhl
Copy link

mrtnuhl commented Jun 5, 2018

<3 Great

Copy link

ghost commented Jun 21, 2018

Thanks!

@maaaaaaaax
Copy link

Still works in July 2018. Thanks!

@rewdt
Copy link

rewdt commented Sep 6, 2018

its not reponsive for smaller screens

@sxhmilyoyo
Copy link

I change a little bit. The text center could be in the middle of the image.

.thumbnailaaa {
    position: relative;
}

.captionaaa {
    position: absolute;
    margin: 0;
    top: 50%;
    left: 50%;
    margin-right: -50%;
    transform: translate(-50%, -50%);
}

@Buxey
Copy link

Buxey commented May 16, 2019

Thanks!

@Vanevo00
Copy link

I really don't understand why should I use Bootstrap.. This stuff I can do in vanilla css with the same amount of work

@f1dz
Copy link

f1dz commented Sep 28, 2019

Super like this

@myusrilh
Copy link

myusrilh commented Dec 6, 2019

thank you mate, it's really helpful :D

@jenninexus
Copy link

I really don't understand why should I use Bootstrap.. This stuff I can do in vanilla css with the same amount of work

I think it's for noobs like me who are still trying to figure out css, but after a few months of using Bootstrap I think I'm understanding a lot more ! :-D Hope to get good.

@kanlukasz
Copy link

kanlukasz commented Mar 4, 2020

If you want to do this without extra css, you can use Card

My example:

<div class="card overflow-hidden border-0 rounded-0 text-center">
	<img src="...." class="card-img rounded-0" alt="...">
	<div class="card-img-overlay d-flex flex-column justify-content-center">
		<a class="stretched-link" href="...">
			<h3 class="card-title text-uppercase">Lorem ipsum</h3>
		</a>
	</div>
</div>

@tonyadastra
Copy link

Very helpful, thank you!

@SenaOzcn
Copy link

SenaOzcn commented Nov 8, 2021

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment