سؤال

Is there a possibility to suppress the automatic breaks in CGI after i use the p-tag?

#!/usr/bin/perl -w

use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $cgi = new CGI;
print $cgi->header();
print $cgi->start_html();
print $cgi->img({ -src => "http://127.0.0.1/pic2.png", -align => "left" });
print $cgi->p({ -align => "middle" }, "Projekt Zeus");
print $cgi->img({ -src => "http://127.0.0.1/pic1.png", -align => "right" });
print $cgi->end_html();

Right now the problem is that the second picture appears in a new row.

هل كانت مفيدة؟

المحلول

You are generating a p element between the two img elements. By default, a p element is rendered as a block and with some margin above and below. The align attributes modify the rendering, but to make the images appear on both sides of the text, change the order so that both img elements precede the p element, i.e. use the order

print $cgi->img({ -src => "http://127.0.0.1/pic2.png", -align => "left" });
print $cgi->img({ -src => "http://127.0.0.1/pic1.png", -align => "right" });
print $cgi->p({ -align => "middle" }, "Projekt Zeus");
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top