responsive style for image

This commit is contained in:
Celogeek 2023-05-01 11:07:38 +02:00
parent 8b04cbc38f
commit 3f874dc43e
Signed by: celogeek
SSH Key Fingerprint: SHA256:njNJLzoLQdbV9PC6ehcruRb0QnEgxABoCYZ+0+aUIYc
3 changed files with 4 additions and 10 deletions

View File

@ -85,11 +85,5 @@ func (i *Image) ImgStyle(viewWidth, viewHeight int, align string) string {
} }
} }
return fmt.Sprintf( return fmt.Sprintf("top:%.2f%%; %s;", marginH*100/float64(viewHeight), align)
"width:%dpx; height:%dpx; top:%.2f%%; %s;",
i.Width,
i.Height,
marginH*100/float64(viewHeight),
align,
)
} }

View File

@ -15,4 +15,6 @@ img {
margin:0; margin:0;
padding:0; padding:0;
z-index:0; z-index:0;
max-width:100%;
max-height:100%;
} }

View File

@ -8,8 +8,6 @@
<meta name="viewport" content="{{ .ViewPort }}"/> <meta name="viewport" content="{{ .ViewPort }}"/>
</head> </head>
<body> <body>
<div> <img src="../{{ .ImagePath }}" alt="{{ .Title }}" style="{{ .ImageStyle }}"/>
<img src="../{{ .ImagePath }}" alt="{{ .Title }}" style="{{ .ImageStyle }}"/>
</div>
</body> </body>
</html> </html>