Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML/CSS element position

Tags:

html

css

I would like to know how can I position this ring in exact same position? I mean when I resize window it does not stay in the same place. I understand that i should not use top or left like I did here but I just don't know what to use here.

.container{
  border-style: solid;
}

.gps_ring {

	border: 3px solid #363347;
 
	-webkit-border-radius: 32px;
	border-radius: 32px;
 
	height: 10px;
	width: 10px;
 
	-webkit-animation: pulsate 1s ease-out;
	-webkit-animation-iteration-count: infinite;
 
	animation: pulsate 1s ease-out;
	animation-iteration-count: infinite;
 
	opacity: 0.0;
	top: 30%;
	left: 50%;
	position: absolute;
}
 
/* webkit - safari, chrome */
@-webkit-keyframes pulsate {
0% {-webkit-transform: scale(0.1, 0.1); opacity: 0.0;}
50% {opacity: 1.0;}
100% {-webkit-transform: scale(1.2, 1.2); opacity: 0.0;}
}
/* no vendor prefix - firefox */
@keyframes pulsate {
0% { transform: scale(0.1, 0.1); opacity: 0.0; }
50% { opacity: 1.0; }
100% { transform: scale(1.2, 1.2); opacity: 0.0; }
}
<div class="container">
  <img src="http://www.pngmart.com/files/3/Australia-Map-Transparent-PNG.png">
  <div class="gps_ring"></div>
</div>
like image 932
Valdas S Avatar asked Aug 10 '26 21:08

Valdas S


2 Answers

If you add position relative to your container, the absolute positioning references the height and size of the container.

.container{
  position: relative;
  border-style: solid;
}

Here's the fiddle:

https://jsfiddle.net/3f9d629m/2/

like image 96
osanger Avatar answered Aug 13 '26 11:08

osanger


.container{
  border-style: solid;
}

.gps_ring {

	border: 3px solid #363347;
 
	-webkit-border-radius: 32px;
	border-radius: 32px;
 
	height: 10px;
	width: 10px;
 
	-webkit-animation: pulsate 1s ease-out;
	-webkit-animation-iteration-count: infinite;
 
	animation: pulsate 1s ease-out;
	animation-iteration-count: infinite;
 
	opacity: 0.0;
	top: 5em;
	left: 19rem;
	position: absolute;
}
 
/* webkit - safari, chrome */
@-webkit-keyframes pulsate {
0% {-webkit-transform: scale(0.1, 0.1); opacity: 0.0;}
50% {opacity: 1.0;}
100% {-webkit-transform: scale(1.2, 1.2); opacity: 0.0;}
}
/* no vendor prefix - firefox */
@keyframes pulsate {
0% { transform: scale(0.1, 0.1); opacity: 0.0; }
50% { opacity: 1.0; }
100% { transform: scale(1.2, 1.2); opacity: 0.0; }
}
<div class="container">
  <img src="http://www.pngmart.com/files/3/Australia-Map-Transparent-PNG.png">
  <div class="gps_ring"></div>
</div>
like image 28
Sahil Dhir Avatar answered Aug 13 '26 11:08

Sahil Dhir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!