I have tried the solutions in here, here, here and many other sources but I can't seem to get what I want.
I'm using Kickstart template and I want to have an image and text/elements centered (horizontally and vertically) on it. This is what I have:
<div class="grid">
<div class="col_12" style="margin-top:50px;" >
<div class="mainImage">
<h2>h2 Text</h2>
<h3>h3 Text</h3>
</div>
</div>
And my CSS:
.mainImage {
height:400px;
width:100%;
background-image: url(img/Customers.png);
text-decoration:line-through;
display: flex;
justify-content: center; /* align horizontal */
align-items: center; /* align vertical */
}
I have tried
display: table-cell; vertical-align: middle;
but these don't work.
Most solutions involve specifying a width. But I do not want to specify a width as I want the page to be responsive. If I use display:table it makes my background image smaller.
What I want is to: 1. Have an image in its own size 2. Have elements centered on it
Any suggestions I can try out?
Thank you.
didn't work in this case. – madu Apr 15 '14 at 01:09