-2

i want to ask how to print my image in center by using perl cgi here is my code :

print img({src=>"/image.png",width=>"200px",hight=>"100px"}),

i tried:

print img({-align=>CENTER}, {src=>"/image.png",width=>"200px",hight=>"100px"}),

but it's not working

haukex
  • 2,973
  • 9
  • 21
  • "it's not working" is not exactly helpful. Have you read the stackoverflow's help pages on how to ask a question? – Yannis Feb 20 '18 at 10:42
  • 2
    You wrote `hight` instead of `height`. I don't know whether it solves your problem. – Mario Cianciolo Feb 20 '18 at 11:09
  • 1
    Not that I want to encourage you to continue using this very outdated style of HTML and means of generating it, but shouldn't the align bit go into the same hash reference as everything else – Chris Turner Feb 20 '18 at 11:26
  • @ChrisTurner You are correct, it should - plus `CENTER` should be in quotes. – haukex Feb 20 '18 at 11:30

1 Answers1

1

This is more of a HTML/CSS question. See Center image using text-align center? - applying that here:

print img({style=>"display:block;margin: 0 auto;",
    src=>"/image.png",width=>"200px",height=>"100px"});

Or use a CSS class and put class=>"classname" in the hashref instead of style.

haukex
  • 2,973
  • 9
  • 21