I’ve used margin: 0 auto; on my two GIF images and also the following properties: bottom, left, right.
It worked very well because my intention was to set them between another image.
However, under these images there is one p element and here is the problem – after setting the position of the two gifs, the site extends because a gap shows up. Part of my code:
#lfinger, #rfinger {
display: block;
position: relative;
margin: 0 auto;
width: 150px;
height: 130px;
}
#rfinger {
bottom: 250px;
right: 270px;
}
#lfinger {
bottom: 145px;
left: 262px;
}
p {
background-color: rgba(255,0,255,0.5);
text-shadow: 1px 1px 10px dimgrey;
text-align: center;
word-spacing: 2px;
font-family: Brush Script MT, Cursive;
font-size: 20px;
color: Ivory;
padding: 10px 0;
position: relative;
}
html:
<img id="lfinger" src="images/left.gif" alt="left">
<img id="rfinger" src="images/right.gif" alt="right">
I’d tried to change the height property to max, min, and auto but no results so far.
I guess an additional property should be added to the ID selector rfinger and lfinger.
2
Answers
I did the way you said, using the first method but slightly modify the code.
Added negative margin-bottom to the double #lfinger, #rfinger ID Selector.
Also added margin: to the p element. I used the shorthand property, setting the top-margin and the rest of values to 0 0 0.
Thanks.
position relative allows to move an element without moving other elements, but you still have space reserved for your element.
In your case, either add a negative margin-bottom equal to the bottom(bottom: 250px; margin-bottom: 250px;)
or
wrap your #lfinger, #rfinger and other images with relative container,
and #lfinger, #rfinger make position: absolute