{"title":"Positioning Layers","id":51939,"link":"https:\/\/env.averta.net\/en\/step\/positioning-layers\/","parent":[51827],"content":"<h2>Locating layers<\/h2>\n<p>To locate a layer over a slide, use <code>data-offset<\/code> attribute. The attribute value can contain multiple parameters.<\/p>\n<h3>Parameter definition pattern<\/h3>\n<p>To add offset parameters, they should be added between <code>{<\/code> and <code>}<\/code> and parameter values define by <code>param:value<\/code> pattern, and like CSS, separated by <code>;<\/code>. For example <code>data-offset=\"{ x:30px; y:100px; origin:mc; }\"<\/code><\/p>\n<h3>Offset parameters<\/h3>\n<table>\n<thead>\n<tr>\n<td>Name<\/td>\n<td>Description<\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>x<\/td>\n<td>Specifies the layer position horizontally relative to layer origin in pixels or percentage (<code>x:100px;<\/code> or <code>x:20%<\/code>).<\/td>\n<\/tr>\n<tr>\n<td>y<\/td>\n<td>Specifies the layer position vertically relative to layer origin in pixels or percentage (<code>y:100px;<\/code> or <code>y:20%<\/code>).<\/td>\n<\/tr>\n<tr>\n<td>width<\/td>\n<td>Specifies the layer width size in pixels or percentage.<\/td>\n<\/tr>\n<tr>\n<td>height<\/td>\n<td>Specifies the layer height size in pixels or percentage.<\/td>\n<\/tr>\n<tr>\n<td>origin<\/td>\n<td>Lets you modify the origin of the layer position. Default value is <code>tl<\/code>.<br \/>\nPossible values are:<\/p>\n<ul>\n<li><code>tl<\/code> &#8211; Position from the top and left.<\/li>\n<li><code>tc<\/code> &#8211; Position from the top and center.<\/li>\n<li><code>tr<\/code> &#8211; Position from the top and right.<\/li>\n<li><code>ml<\/code> &#8211; Position from the middle and left.<\/li>\n<li><code>mc<\/code> &#8211; Position from the middle and center.<\/li>\n<li><code>mr<\/code> &#8211; Position from the middle and right.<\/li>\n<li><code>bl<\/code> &#8211; Position from the bottom and left.<\/li>\n<li><code>bc<\/code> &#8211; Position from the bottom and center.<\/li>\n<li><code>br<\/code> &#8211; Position from the bottom and right.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td>absolute<\/td>\n<td>Enabled by default. Disabling this option (<code>absolute:false;<\/code>) lets you set the layer to get position relatively to its parent element. It is useful when you are adding a layer inside a column grid or you want to control the layer positioning with CSS and media queries. Disabling this option ignores <code>x<\/code>, <code>y<\/code> and <code>origin<\/code> parameters.<\/td>\n<\/tr>\n<tr>\n<td>contentAlign<\/td>\n<td>Specifies alignment of the layer content when the <code>absolute<\/code> parameter is disabled. Possible values are <code>left<\/code>, <code>right<\/code> and <code>center<\/code>.<\/td>\n<\/tr>\n<tr>\n<td>inline<\/td>\n<td>Enabling this option adds display inline style to the layer element, it is useful when you need to add two or more layers in a line. This parameter is only effective if the <code>absolute<\/code> is disabled.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The following example locates the layer from the center of the slider:<\/p>\n<pre class=\"lang:xhtml decode:true \">\t&lt;div id=\"masterslider\" class=\"master-slider\"&gt;\r\n\t\t&lt;div class=\"ms-slide\"&gt;\r\n\t\t\t&lt;!-- ... --&gt;\r\n\t\t\t\t&lt;div class=\"ms-layer\"\r\n\t\t\t\t\t data-type=\"text\"\r\n\t\t\t\t\t data-offset=\"{ origin:mc; x:100px; y:-100px; width:95px; }\"\r\n\t\t\t\t&gt;\r\n\t\t\t\t\tText layer content\r\n\t\t\t\t&lt;\/div&gt;\r\n\t\t\t&lt;!-- ... --&gt;\r\n\t\t&lt;\/div&gt;\r\n\t\t&lt;!-- ... --&gt;\r\n\t&lt;\/div&gt;<\/pre>\n<h3>Relocate the layer in a breakpoint<\/h3>\n<p>If you need to change the layer position on a <a href=\"https:\/\/env.averta.net\/en\/step\/defining-breakpoints\/?b=51990,51990\" title=\"Defining Breakpoints\">breakpoint<\/a>, you can set a new offset attribute with the breakpoint name. For example,?<code>data-tablet-offset=\"{ origin:tl; x:100px; y: 150px;}\"<\/code>. In the following example, the text layer relocates in the tablet and mobile devices:<\/p>\n<pre class=\"lang:xhtml decode:true \">\t&lt;div id=\"masterslider\" class=\"master-slider\"&gt;\r\n\t\t&lt;div class=\"ms-slide\"&gt;\r\n\t\t\t&lt;!-- ... --&gt;\r\n\t\t\t\t&lt;div class=\"ms-layer\"\r\n\t\t\t\t\t data-type=\"text\"\r\n\t\t\t\t\t data-offset=\"{ origin:mc; x:100px; y:-100px; width:95px; }\"\r\n\t\t\t\t\t data-tablet-offset=\"{ origin:bl; x:0; y:100px; width:100px; }\"\r\n\t\t\t\t\t data-mobile-offset=\"{ origin:tr; x:10px; y:10px; }\"\r\n\t\t\t\t&gt;\r\n\t\t\t\t\tText layer content\r\n\t\t\t\t&lt;\/div&gt;\r\n\t\t\t&lt;!-- ... --&gt;\r\n\t\t&lt;\/div&gt;\r\n\t\t&lt;!-- ... --&gt;\r\n\t&lt;\/div&gt;<\/pre>\n<p class=\"aswi-text-box box-important\"><strong>Important: <\/strong>If the offsets are not defined for smaller breakpoints, the layer considers the first defined offset for the larger breakpoint. For example when the mobile offset is not set, the tablet offset will be considered for the mobile size instead of?<code>data-offset<\/code> value.<\/p>\n<p class=\"aswi-text-box box-info\"><strong>Note: <\/strong>Breakpoint names are defined by breakpoint option. For more information check out <a href=\"https:\/\/env.averta.net\/en\/step\/defining-breakpoints\/?b=51990,51990\" title=\"Defining Breakpoints\">Breakpoints<\/a> article.<\/p>\n<h3>Hide layer in a breakpoint<\/h3>\n<p>If you need to hide a layer in a breakpoint, you can set <code>hidden:true<\/code> parameter in the offset attribute. For example,?<code>data-tablet-offset=\"{hidden:true;}\"<\/code> hides the layer on tablet and mobile sizes.<\/p>\n<h2>Wrapping layers<\/h2>\n<p>It is optional to set the layer to wrap with the wrapper container. The wrapper container appears in the center of the slider and its max-width sets by slider <code>width<\/code> option. If your slider is <code>boxed<\/code>, the wrapper container gets the same width as the slider&#8217;s. Therefore, this will make more difference if the slide is <code>fullscreen<\/code> or <code>fullwidth<\/code>. By default, all the layers wrap by the wrapper. To disable it, you can add <code>data-wrap=\"false\"<\/code> attribute to the layer element.<\/p>\n<h2>Resizing layer<\/h2>\n<p>Layers resize when the slider resizes by the browser window or gets smaller in a mobile device screen. You can set how a layer reacts to the slider resizing by the following attributes:<\/p>\n<ul>\n<li><code>data-resize<\/code> &#8211; Disables layer resizing (<code>data-resize=\"false\"<\/code>).<\/li>\n<li><code>data-fixed<\/code> &#8211; Let you to set the layer fixed when the slider resizes. (<code>data-fixed=\"true\"<\/code>).<\/li>\n<li><code>data-reset-scale<\/code> &#8211; Enabling this option resets the layer scaling after each breakpoint (<code>data-reset-scale=\"true\"<\/code>).<\/li>\n<li><code>data-upscale<\/code> &#8211; Disabling this option prevents layer to get larger that its actual size in large screen sizes. (<code>data-upscale=\"false\"<\/code>).<\/li>\n<\/ul>\n<h2>Layer position attribute<\/h2>\n<p>You can set how the layer gets position by <code>data-position<\/code> attribute. Default value is <code>normal<\/code>. Possible values are:<\/p>\n<ul>\n<li><code>normal<\/code> &#8211; Slide layer moves by slide when the slide changes.<\/li>\n<li><code>fixed<\/code> &#8211; Slide layer remains stationary when the slide changes.<\/li>\n<li><code>static<\/code> &#8211; It is same as <code>normal<\/code>, but the static layer is not animatable. It is useful to add a content without any animation and stationary over a slide, or over the slider as an overlay layer.<\/li>\n<\/ul>\n","type":"solution"}