Okay, so this is the parent div:
#left {
width: 50%;
height: 100%;
background-color: #8FD1FE;
float: left;
opacity:0.75;
filter:alpha(opacity=75);
-webkit-transition: all .45s ease;
-moz-transition: all .45s ease;
transition: all .45s ease; }
And this is the div inside the div:
#reasons {
background-image:url('arrow1.png');
background-repeat: no-repeat;
height: 94px;
width: 400px;
margin: 0 auto 0 auto; }
I've tried a bunch of different methods, but I can't seem to keep the the second div centered and stuck to the bottom of the first div.
Just set the parent div with position:relative . Then, the inner item you want to stick to the bottom, just use position:absolute to stick it to the bottom of the item.
The most common way to place two divs side by side is by using inline-block css property. The inline-block property on the parent placed the two divs side by side and as this is inline-block the text-align feature worked here just like an inline element does.
Without using position: absolute , you'd have to vertically align it. You can use vertical-align: bottom which, according to the docs: The vertical-align CSS property specifies the vertical alignment of an inline or table-cell box.
To place a div in bottom right corner of browser or iframe, we can use position:fixed along with right and bottom property value assigned to 0.
First, make the outer div
a layout parent:
#left {
/* ... */
position: relative; /* anything but static */
/* ... */
}
Now let's fix the inner div
to the bottom:
#reasons {
/* ... */
position: absolute;
bottom: 0;
/* ... */
}
Now it's fixed to the bottom, but we need to center it:
#reasons {
/* ... */
left: 50%;
margin: 0 0 0 -200px; /* 200px is half of the width */
/* ... */
}
See a demo on JSFiddle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With