imagen css centrada

1 Pase de posición de fondo

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>background-position</title> 
<style>
div
{
     
      
	height:40px;
	width:40px;
	background-color:blue;
	background-image:url('https://www.runoob.com/try/smiley.gif');
	background-repeat:no-repeat;
	background-position:center
}
</style>
</head>

2 Use la etiqueta img y luego centre la etiqueta img del elemento en línea, sin usar el atributo de imagen de fondo

Supongo que te gusta

Origin blog.csdn.net/qq_26889291/article/details/109091755
Recomendado
Clasificación