Skip to content

Instantly share code, notes, and snippets.

@petehouston
Created October 17, 2014 07:20
Show Gist options
  • Select an option

  • Save petehouston/85dd33210c0764eeae55 to your computer and use it in GitHub Desktop.

Select an option

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%;
}
@Ludovicmoreau

Copy link
Copy Markdown

thank you !

@NikkoDomingo

Copy link
Copy Markdown

deal
How can i do this kind of ovelay text thanks

@desiba

desiba commented Feb 8, 2017

Copy link
Copy Markdown

thank you

@xabispacebiker

Copy link
Copy Markdown

This is so nice, thank you !

@Fefein

Fefein commented May 23, 2017

Copy link
Copy Markdown

Thanks a lot

@monishRahane05

Copy link
Copy Markdown

Awesome

@sandy02

sandy02 commented Jun 7, 2017

Copy link
Copy Markdown

Thank you !!

@willardshikami

Copy link
Copy Markdown

Thanks alot!!

@KonanFrancko

Copy link
Copy Markdown

good morning you saved my day too thank you!

@hermanaguirrej

Copy link
Copy Markdown

Thank you very much!

@jmubago

jmubago commented Apr 2, 2018

Copy link
Copy Markdown

Very helpful mate!

@platadani

Copy link
Copy Markdown

Thank you!

@martinuhlr

Copy link
Copy Markdown

<3 Great

ghost commented Jun 21, 2018

Copy link
Copy Markdown

Thanks!

@maaaaaaaax

Copy link
Copy Markdown

Still works in July 2018. Thanks!

@rewdt

rewdt commented Sep 6, 2018

Copy link
Copy Markdown

its not reponsive for smaller screens

@sxhmilyoyo

Copy link
Copy Markdown

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

Buxey commented May 16, 2019

Copy link
Copy Markdown

Thanks!

@Vanevo00

Copy link
Copy Markdown

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

f1dz commented Sep 28, 2019

Copy link
Copy Markdown

Super like this

@myusrilh

myusrilh commented Dec 6, 2019

Copy link
Copy Markdown

thank you mate, it's really helpful :D

@jenninexus

Copy link
Copy Markdown

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

kanlukasz commented Mar 4, 2020

Copy link
Copy Markdown

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
Copy Markdown

Very helpful, thank you!

@SenaOzcn

SenaOzcn commented Nov 8, 2021

Copy link
Copy Markdown

thank you!

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