Home Forums General XMetaL Discussion CSS to model a mobile view Reply To: CSS to model a mobile view

Derek Read

Reply to: CSS to model a mobile view

You are correct that CSS support is not complete. Basically most of CSS 2 is supported, including many things browsers don't support (or are just now starting to support) and many things that browsers support because they make sense when reading but not while editing a document. You can find a (mostly correct) list of what is supported in the XMetaL Developer Customization Guide.

Basically we provide enough CSS for authoring to give you a reasonable representation of what output might look like, but not everything (lots of people don't even output to HTML so browsers are irrelevant to them but PDF or other outputs are). Ideally what you'd want here is to be able to specify a width like the following, assuming

is some main portion of your document that contains most of the rest of it, such as the assumed root element in the Journalist sample:

Article{display:block; width:200px}

The CSS width property isn't supported though, so it won't do anything.

You could try putting your content into a single-celled table (HTML or CALS) where you can control the width, but then you're going to need to change your document model and deal with that in any transforms you do. Might work for some people in some cases (we had a client do that years ago) but I think that's overkill for such a simple problem as I understand yours to be (particularly when you might want to check various sizes).

Option 1:
What I would do is to size the editing window for the current document to roughly the right width. There are no APIs that will do this for you, so you'll need to ask the user to do that manually. If you don't mind making a change to your CSS to aid with the sizing (which would still be manual) that you could display an image somewhere in the document using CSS :before pseudo-element, something like so:

Article:before{display:block; margin-left:-10px; content:url(ruler.png)}

See attached screenshot. I'm including the image I used for the selector above as well in case you want to use it instead of creating your own.

Note that that path (ruler.png) is relative to the CSS file itself, so you will need to place the png in the same folder for XMetaL to locate it. If using XMetaL Developer to build your customization you can bundle it into the project, but ultimately it doesn't matter much as long as you get it into the same folder as your CSS file using whatever method you use to distribute your customization files to your authors.

Option 2:
An alternative would be to obtain one of several tools (most are shareware or freeware) that allow you to size a particular application to a specific dimension in pixels. These are usually designed to resize web browsers to 640×480, 1024×768, etc, to allow web designers to test their layout based on different user preferences for screen resolution (when a browser is maximized) without needing to actually change those settings. I think you usually set the size of the app in the tool then trigger it somehow by clicking on the app you want to resize. In this case you wouldn't change your CSS at all, and you would leave your document maximized inside XMetaL Author, but just resize the entire application. You'd need to take internal window sizes for the Element List, Attribute Inspector and Resource Manager into account in this case of course if they are open.