Thickness.toCSSFormat

Syntax

toCSSFormat(propertyName: String);

Parameters

propertyName. Name of the property, for which margin settings must be applied.

Description

The toCSSFormat method returns the string in the CSS format with indent settings.

Example

To execute the example, the HTML page must contain links to the jquery.js, PP.js scenario files, and the PP.css styles file. Create a div element:

// Create a div element
var divElem = PP.createElement(document.body);
// Set up styles for this element
divElem.style.cssText = "width: 200px; height: 100px; border: 1px solid rgb(102, 102, 102);";
// Create a SVG element with a rectangle
var svgElem = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svgElem.setAttribute("width", "200");
svgElem.setAttribute("height", "100");
var rectElem = document.createElementNS("http://www.w3.org/2000/svg", "rect");
rectElem.setAttribute("x", "0");
rectElem.setAttribute("y", "0");
rectElem.setAttribute("width", "160");
rectElem.setAttribute("height", "60");
rectElem.setAttribute("fill", "#a3c8fc");
svgElem.appendChild(rectElem);
divElem.appendChild(svgElem);

After executing the example a div element is created in the document, in which a rectangle is placed:

Then set new margin values for the rectangle placed in the div element:

// Create an object with svg element margin values
var margin = new PP.Thickness({
    Left: 20,
    Top: 20
});
// Set svg element margins
svgElem.style.cssText = margin.toCSSFormat("margin");

As a result new margin values are set for the rectangle placed in the div element:

Thickness