Web component HTML layout
Stretchable WEBCOMPOMENT form field
WEBCOMPONENT
form field with the following
attributes:WEBCOMPONENT wc1=FORMONLY.wc1,
COMPONENTTYPE="mywebcomp",
SIZEPOLICY=FIXED,
STRETCH=BOTH,
SCROLLBARS=NONE;
Viewport zooming on mobile devices
name='viewport'
in the HTML file of your gICAPI-based web components, with
initial and maximal scale attributes set to
1:<meta name='viewport' content='initial-scale=1.0, maximum-scale=1.0' />
HTML body auto-resize
In order to force the resizing of the HTML content to the parent container, use the following CSS style:
<style>
html,body {
height:100%;
padding:0;
margin:0;
border:0;
}
...
</style>
Controlling SVG layout
When displaying SVG inside your web component, you need to define how the SVG adapts to the parent container.
SVG root elements define their own viewport (width
and height
attributes), and local layout rules through viewBox
and
preserveAspectRatio
attributes.
For general purpose, do not set the width
and height
attributes in your root SVG element, and use preserveAspectRatio="xMidYMid meet"
.
In the CSS style of the HTML page, define CSS styles for a parent div and for the svg root element, depending on the needs (to get scrollbars for example):
<style>
...
.svg_container_nsb {
overflow: hidden;
}
.svg_container_hsb {
overflow-x: scroll;
overflow-y: hidden;
}
.svg_container_vsb {
overflow-x: hidden;
overflow-y: scroll;
}
.root_svg_max_h {
max-height: 100%;
}
.root_svg_h_max_h {
height: 100%;
max-height: 100%;
}
...
</style>
Control the layout of the svg root element by using the appropriate CSS styles (typically set when building your SVG by program):
<body>
<div id="svg_container" class="svg_container_nsb">
<svg . viewBox="-15 -10 158 143" preserveAspectRatio="xMidYMid meet" ... class="root_svg_max_h" ...>
...
</svg>
</div>
</body>
<body>
<div id="svg_container" class="svg_container_vsb">
<svg ... viewBox="-20 -7 268 727" preserveAspectRatio="xMidYMin slice" ... >
...
</svg>
</div>
</body>
<body>
<div id="svg_container" class="svg_container_hsb">
<svg ... viewBox="-20 -7 268 727" preserveAspectRatio="xMidYMin slice" class="root_svg_h_max_h" ... >
...
</svg>
</div>
</body>