Flare 4: DIV with background image for warnings

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
JupiterJones
Propeller Head
Posts: 42
Joined: Fri May 23, 2008 2:09 am

Flare 4: DIV with background image for warnings

Post by JupiterJones »

Hello,

I am looking for an easy and comfortable way to create "single-sourcing warning boxes" (CHM and direct PDF) including a warning symbol and two or three paragraphs/lists with warning text on the right. And the whole object should have a border line.

My idea was to group the paragraphs using a div element and to configure the div class with a border and a background image for the warning symbol (low resultion symbol for non-print medium, high resolution symbol for print).
Well, this still looks quite good in the XML Editor. Then the problems start...

In CHM, the background image is displayed as intended. The problem is that I cannot fully control the position of the image. I have used parameter "background-position", which allows to define x and y offsets from the top left corner. Assigning just the x value works. But as soon as I also try to specify a Y value, the image is not displayed at all - even in the XML Editor. WHY???
The style property I used initially was: "background-position:15px 15px;". Then I had to remove the y value, otherwise there was no image.

It gets even worse when I try to generate the PDF target:
First, the dpi (300 in this case) seems to be ignored, the image is much too large and low resoluted (approx. 72 dpi).
Second, the image position is completely out of range (even partly outside the div area), and it is cropped at the bottom end.

For the print medium I also experimented with the background-position, but it only made things worse. There seemed to be no logical behaviour and the image appeared just somewhere on the page...

Do you have an idea, what's going wrong here? Is there a better way to create such warnings?
I would like to avoid a solution using tables, table styles etc. - the div solution would be so nice and easy...

Thanks in advance for your help!
JJ
You do not have the required permissions to view the files attached to this post.
lacastle
Propellus Maximus
Posts: 1028
Joined: Thu Apr 12, 2007 7:28 am
Location: Wilmington, DE
Contact:

Re: Flare 4: DIV with background image for warnings

Post by lacastle »

Have you seen this topic - http://forums.madcapsoftware.com/viewto ... t=note+box
I haven't tried it, but I think it's kind of similar to what you're trying to do.
JupiterJones
Propeller Head
Posts: 42
Joined: Fri May 23, 2008 2:09 am

Re: Flare 4: DIV with background image for warnings

Post by JupiterJones »

Hi Laura,

thanks for your reply.
Yes, that's a similar idea. I tried to define the background image for the div class, in that article they use a auto-number text "Note" with a span style and a background-image.
Since I don't need the text, I would prefer the less complicated div solution.

But currently I would take ANY solution that WORKS! I tried the example (with almost identical styles), but I can see no image! Not in XML Editor, CHM, PDF.

Do you have any ideas?

Thanks,
JJ
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Flare 4: DIV with background image for warnings

Post by LTinker68 »

I do something similar, but I'm using a custom <p> class instead of a DIV. It shows up in the XML Editor, in CHM output, and in PDF output, although it's slightly cut off in the PDF output so I'll have to play with the style in the print medium a bit. It doesn't show up in Word output, but Word doesn't like DIVs either, or even custom images for bullets, so that one wasn't too surprising.

Here are the properties I have for the custom <p> class. Maybe that will help. The imgNote graphic is 33x40 px.

Code: Select all

p.note
{
	background-image: url('../Images/imgNote.gif');
	background-repeat: no-repeat;
	padding-top: 6px;
	min-height: 46px;
	margin-left: 40px;
	padding-left: 40px;
	margin-right: 80px;
}
Could you post the styles you're using for the DIV?
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
KevinDAmery
Propellus Maximus
Posts: 1985
Joined: Tue Jan 23, 2007 8:18 am
Location: Darn, I knew I was around here somewhere...

Re: Flare 4: DIV with background image for warnings

Post by KevinDAmery »

Y'know, you could cheat and just add 15px to the top and left of the graphic....
Until next time....
Image
Kevin Amery
Certified MAD for Flare
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Flare 4: DIV with background image for warnings

Post by LTinker68 »

That might not help the PDF issue, though. If modifying the stylesheet doesn't work then I could always use two graphics -- one for online output and one for print. I'll have to play with that to see if I can get it to work.

I do like the fact that the image at least partially appears in PDF output, since it doesn't appear at all in Word. I don't have any custom bullet images in this project, but I'm hoping those will appear in PDF output, too.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
JupiterJones
Propeller Head
Posts: 42
Joined: Fri May 23, 2008 2:09 am

Re: Flare 4: DIV with background image for warnings

Post by JupiterJones »

I have tried quite a few different approaches for styling my warning boxes comfortably.
The following solution now works for me:

The box is created using a div class, but without background image - would be nice, but doesn't work due to PDF issue (image cut off) and positioning problems (background-position creates strange results).

The image is now embedded (normal image tag) in the first paragraph as "floating left" with a margin-right of 15px. All paragraphs have a margin-left of e.g. 80px to indent them. The image class has a position shift of "left:-80px". Thereby the image is displayed on the left, the paragraphs beautifully aligned on the right.
Surprisingly, for the PDF target I had to remove the margin-left for the first paragraph which includes the image, but now it also works for PDF.

The image size for each medium is controlled using the new parameter max-width - which finally creates nicely resampled versions of the resized image.
The whole block is now embedded in a snippet - I had to create one snippet for each warning symbol - and whenever I now need a warning box, I insert the desired snippet, convert it to text and enter the warning text - works fine for me!

Thanks for your help,
Jörg
You do not have the required permissions to view the files attached to this post.
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: Flare 4: DIV with background image for warnings

Post by doc_guy »

Could you post a sample of the CSS and the XHTML that creates this effect for other users who might be interested? Alternatively, you might post an entry in the Tips/Tricks forum with the info.
Paul Pehrson
My Blog

Image
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: Flare 4: DIV with background image for warnings

Post by doc_guy »

Oh, good work, by the way.
Paul Pehrson
My Blog

Image
SteveS
Senior Propellus Maximus
Posts: 2089
Joined: Tue Mar 07, 2006 5:06 pm
Location: Adelaide, far side of the world ( 34°56'0.78\"S 138°46'44.28\"E).
Contact:

Re: Flare 4: DIV with background image for warnings

Post by SteveS »

I use a table approach. This code code works in Flare III but I haven't tested in Flare IV yet.

The table looks like this in the XML editor:
tip dialog.png
The code for the table:

Code: Select all

<table align="center" class="message">
            <col style="width: 150px;" />
            <col style="width: auto;" />
            <tr>
                <td class="headingL" style="text-align: center;">
                </td>
                <td class="headingR" style="text-align: center;">
                    <p class="headstyle">Tip</p>
                </td>
            </tr>
            <tr>
                <td class="icon" style="text-align: center;">
                    <p class="iconstyle">
                        <img src="../Resources/Images/Warnings/tip.png" />
                    </p>
                </td>
                <td class="definition" style="text-align: center;">
                    <p class="MessageStyle">A <b>tip</b> is something that will make your life easier. Ignoring a tip will not affect the program.</p>
                </td>
            </tr>
        </table>
And the styleheet stuff:

Code: Select all

p.headstyle
{
	text-align: center;
	font-weight: bold;
	font-size: 1.25em;
	margin-top: .25em;
	margin-bottom: 0em;
}

p.iconstyle
{
	text-align: center;
}

table.message
{
	align: center;
	margin-right: 1pt;
	margin-left: 1pt;
	background-color: LightYellow;
	border-collapse: collapse;
	width: 85%;
}

td.headingL
{
	border-top-style: solid;
	border-top-width: 2pt;
	border-top-color: black;
	border-left-style: solid;
	border-left-width: 2pt;
	border-left-color: black;
	border-bottom-style: solid;
	border-bottom-width: 1pt;
	border-bottom-color: LightYellow;
	border-right-style: solid;
	border-right-width: 1pt;
	border-right-color: LightYellow;
}

td.headingR
{
	border-top-style: solid;
	border-top-width: 2pt;
	border-top-color: black;
	border-left-style: solid;
	border-left-width: 1pt;
	border-left-color: LightYellow;
	border-bottom-style: solid;
	border-bottom-width: 1pt;
	border-bottom-color: LightYellow;
	border-right-style: solid;
	border-right-width: 2pt;
	border-right-color: black;
}

td.icon
{
	border-top-style: solid;
	border-top-width: 1pt;
	border-top-color: LightYellow;
	border-left-style: solid;
	border-left-width: 2pt;
	border-left-color: black;
	border-bottom-style: solid;
	border-bottom-width: 2pt;
	border-bottom-color: black;
	border-right-style: solid;
	border-right-width: 1pt;
	border-right-color: LightYellow;
	vertical-align: middle;
}

td.definition
{
	border-top-style: solid;
	border-top-width: 1pt;
	border-top-color: LightYellow;
	border-left-style: solid;
	border-left-width: 1pt;
	border-left-color: LightYellow;
	border-bottom-style: solid;
	border-bottom-width: 2pt;
	border-bottom-color: black;
	border-right-style: solid;
	border-right-width: 2pt;
	border-right-color: black;
}
Feel free to play...
You do not have the required permissions to view the files attached to this post.
Image
Steve
Life's too short for bad coffee, bad chocolate, and bad red wine.
JupiterJones
Propeller Head
Posts: 42
Joined: Fri May 23, 2008 2:09 am

Re: Flare 4: DIV with background image for warnings

Post by JupiterJones »

These are the styles I used for my non-table approach:

@media print (PDF)

Code: Select all

	div.WarningBox
	{
		margin-left: 20mm; //since all my paragraphs are indented
		border: solid 1px;
		padding: 3mm;
		margin-top: 12pt;
		page-break-inside: avoid;
	}

	img.symbol
	{
		float: left;
		text-align: left;
		padding-right: 4mm;
	}

	p.WarningSignalwort //first paragraph in box including the image
	{
		
	}
@media non-print (CHM)

Code: Select all

	div.WarningBox
	{
		padding: 8px;
		margin-top: 12pt;
		border: solid 1px;
	}

	img.symbol
	{
		vertical-align: text-top;
		position: relative;
		float: left;
		left: -78px;  //shift to the left
		margin-right: -62px;  //to shift also the text to the left, to its 'original' position
		max-width: 62px;  //resizing the image
	}

	p.WarningSignalwort
	{
		margin-left: 77px; //indent for all paragraphs in the box to place the text on the right
	}
I had to use quite a few css parameters to adjust the positioning of image and paragraphs, especially for CHM.
Strange, that CHM and PDF require such different parameter setting to achieve the same result.
Propably, there is a 'cleaner' solution. However, I am happy that it's working now! ;-)
JupiterJones
Propeller Head
Posts: 42
Joined: Fri May 23, 2008 2:09 am

Re: Flare 4: DIV with background image for warnings

Post by JupiterJones »

Oh, I forgot to add the snippet source code:

Code: Select all

 <div class="WarningBox">
            <p class="WarningSignalwort">
                <img src="../Images/WarningDanger.png" class="symbol" />Danger!</p>
            <p class="WarningGefahrbenennung">Gefahrbenennung</p>
            <ul>
                <li class="WarningAnweisung">Anweisung zur Vermeidung der Gefahr</li>
                <li class="WarningAnweisung">Anweisung zur Vermeidung der Gefahr</li>
            </ul>
</div>
KHHS
Propeller Head
Posts: 10
Joined: Mon Nov 26, 2007 10:33 am
Location: Germany

Re: Flare 4: DIV with background image for warnings

Post by KHHS »

Thank you for sharing your solution, JupiterJones!
I had the same problem with a warning-symbol not showing in pdf, when set up as a background-image.
So i took your approach and changed it a little bit. It has three DIVs (DIV-classes) now, but the advantage is, that i don't need a second set of block-classes (<p>, <ul> etc.) for the warning box. Instead i can use any element inside the "content-DIV".

The outer DIV is used just for the box-border around the warning, margins etc.
Inside it there is one DIV with the Image-Element. This DIV is set to float:left, clear:left
Next to it is the "content-DIV" with a left margin set (different margins for pdf and online-output). Inside this DIV there there are Paragraphs, Lists, whatever. Those don't need special classes.

Code: Select all

<div class="hinweis_box">
            <div class="hinweis_symbol">
                   <img src="../../Images/hinweisimage.gif" />
            </div>
            <div class="hinweis_content">
                <p>Text</p>
                ... 
            </div>
        </div>
This works fine for CHM and PDF-Output. Once saved as a snippet, its easy to apply and handle, apart from the fact, that the floating Image-DIV is not shown in the sidebar of the editor.
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: Flare 4: DIV with background image for warnings

Post by doc_guy »

Just for curiosity's sake: when you have the problems with the background images not showing in your PDF output, are you building on a Windows Vista machine? or Win XP? Because I just moved my Flare 4 project from an XP box to a Vista box, and the background images that were appearing in Flare 4 on XP are no longer appearing in Flare 4 on Vista.
Paul Pehrson
My Blog

Image
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Flare 4: DIV with background image for warnings

Post by LTinker68 »

doc_guy wrote:Just for curiosity's sake: when you have the problems with the background images not showing in your PDF output, are you building on a Windows Vista machine? or Win XP?
I don't use the DIV approach, I use background images on the <p> tag, but during the course of this thread I realized that my background image is being cut off in PDF output, so I'll have to figure out a way to fix that or switch to the DIV method. But to answer your question, Paul, in my case this is happening on an XP machine.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: Flare 4: DIV with background image for warnings

Post by doc_guy »

Not to hijack the thread, but my specific problem is that on XP machines, my background images in page layout frames are showing in PDF, but on Vista (64bit), my background images in page layout frames are not shown in PDF.

I wonder if it is a similar issue or not.
Paul Pehrson
My Blog

Image
JupiterJones
Propeller Head
Posts: 42
Joined: Fri May 23, 2008 2:09 am

Re: Flare 4: DIV with background image for warnings

Post by JupiterJones »

I am also using Windows XP...

JJ
Andrew
Propellus Maximus
Posts: 1237
Joined: Fri Feb 10, 2006 5:37 am

Re: Flare 4: DIV with background image for warnings

Post by Andrew »

doc_guy wrote:Not to hijack the thread, but my specific problem is that on XP machines, my background images in page layout frames are showing in PDF, but on Vista (64bit), my background images in page layout frames are not shown in PDF.

I wonder if it is a similar issue or not.
Not sure if it helps, but background images in page layouts show up fine for me in Vista 32.
Flare v6.1 | Capture 4.0.0
cbdebris
Sr. Propeller Head
Posts: 105
Joined: Wed Aug 15, 2007 4:15 pm
Location: California

Re: Flare 4: DIV with background image for warnings

Post by cbdebris »

More formatting ideas for your consideration. Working in Flare version 4, output to PDF, from XP.

Text for a tip in a box with color, and the word "tip" outside the box, at the left.

Code: Select all

p.tip
	{
		background-color: #fff8e1;
		clear: both;
		margin-bottom: 4pt;
		margin-left: 4em;
		margin-right: 4em;
		mc-auto-number-class: numbr;
		mc-auto-number-format: 'Tip';
		mc-auto-number-position: outside-head;
		mc-auto-number-offset: 3.5em;
		padding: 6pt;
		color: #000000;
		padding-bottom: 10pt;
		font-family: 'Monotype Corsiva';
	}
Text for a warning, in a box with a colour background and the word "Warning" before the beginning of the text, followed by a space. The warning is accompanied by a graphic at the left, outside the box. Writers have to insert the graphic and ensure the graphic is assigned the .img class.

Code: Select all

div.warning:before
	{
		content: 'Warning:  ';
	}

	div.warning
	{
		margin-bottom: 10pt;
		color: #000000;
		margin-top: 4pt;
		background-repeat: no-repeat;
		padding: 0em;
		padding-right: 4pt;
		padding-top: 4pt;
		background-image: none;
		visibility: visible;
		width: auto;
		z-index: auto;
		display: block;
		font-weight: 500;
		font-variant: normal;
		padding-left: 6pt;
		padding-bottom: 6pt;
		font-family: Verdana;
		background-color: #ffe9a6;
		line-height: 120%;
		letter-spacing: -0.5px;
		font-size: 10pt;
		margin-right: 3em;
		margin-left: 6em;
	}
img.WarnGrph
	{
		page-break-after: avoid;
		page-break-before: avoid;
		visibility: visible;
		mc-hyphenate: never;
		page-break-inside: avoid;
		overflow: visible;
		display: inline-block;
		background-color: #ffffff;
		padding-right: 0em;
		height: 31px;
		width: 41px;
		top: auto;
		line-height: 120%;
		font-size: 10pt;
		position: relative;
		padding-bottom: auto;
		margin-right: 1em;
		margin-left: -5.5em;
		float: left;
		margin-top: -16pt;
		font-family: Georgia;
	}
All life is a blur of Republicans and meat. -- Zippy the Pinhead
Post Reply