Images are now centered, both vertically and horizontally
This commit is contained in:
parent
0bdbc5d2a0
commit
0b34784b12
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = "0.25.5"
|
var Version = "0.26.0"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(versionCmd)
|
rootCmd.AddCommand(versionCmd)
|
||||||
|
|
|
@ -220,8 +220,10 @@ func serveHtml(w http.ResponseWriter, r *http.Request, filePath string, dimensio
|
||||||
|
|
||||||
var htmlBody strings.Builder
|
var htmlBody strings.Builder
|
||||||
htmlBody.WriteString(`<!DOCTYPE html><html lang="en"><head>`)
|
htmlBody.WriteString(`<!DOCTYPE html><html lang="en"><head>`)
|
||||||
htmlBody.WriteString(`<style>a{display:block;height:100%;width:100%;text-decoration:none;}`)
|
htmlBody.WriteString(`<style>html,body{margin:0;padding:0;height:100%;}`)
|
||||||
htmlBody.WriteString(`img{max-width:100%;max-height:97vh;object-fit:contain;}</style>`)
|
htmlBody.WriteString(`a{display:block;height:100%;width:100%;text-decoration:none;}`)
|
||||||
|
htmlBody.WriteString(`img{margin:auto;display:block;max-width:97%;max-height:97%;object-fit:scale-down;`)
|
||||||
|
htmlBody.WriteString(`position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);}</style>`)
|
||||||
htmlBody.WriteString(fmt.Sprintf(`<title>%v (%vx%v)</title>`,
|
htmlBody.WriteString(fmt.Sprintf(`<title>%v (%vx%v)</title>`,
|
||||||
fileName,
|
fileName,
|
||||||
dimensions.Width,
|
dimensions.Width,
|
||||||
|
|
Loading…
Reference in New Issue