General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion CSS to model a mobile view

  • jcollins

    CSS to model a mobile view

    Participants 0
    Replies 1
    Last Activity 10 years, 6 months ago

    I've got some authors who are developing content that will be used in several contexts, including on mobile devices.  They'd like to be able to see some sort of Normal View mode that scrunches the text into a narrow column similar to a mobile view.  I'm not talking about some fancy jQuery-esque presentation here.  Just something suitably narrow that it would give an impression of the mobile presentation.  They do want to be able to edit (or tweak, really) in the mobile presentation–which is why I assumed some CSS applied to the Normal View would be a good solution.

    I see there are some handy methods to load new CSS style sheets or append to the current one.  But I can't seem to figure out what CSS styles might be available to me to define a narrow column of text.  Can anybody offer any suggestions?  I'm thinking the CSS in XMetaL is not a full fledged CSS implementation like one might find in a modern browser.  But I don't quite understand what CSS styles are available to me to work with.  I do see that there are options for specifying the margins and border widths.  But those commands seem relative to the application border.  I think I need a way to fix a column width, not the space around it.

    One poor man's solution I was considering in my desperation is to load an image that is the appropriate length for mobile viewing into the document and having them resize the whole application window until it matches the image size.

    Thanks for your help here.

    Reply

    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.

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support