Javascript DOM CSS Style columnFill Property

Introduction

Specify how to fill columns:

document.getElementById("myDIV").style.columnFill = "balance";

Click the button to set the column-fill property of the DIV element to "balance":

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {/*from   ww  w  . ja v a2 s  . co m*/
  column-count: 3;
  height: 100px;
  column-fill: auto;
}
</style>
</head>
<body>

<h1>Change column-fill with JavaScript</h1>
<button onclick="myFunction()">Test</button>

<div id="myDIV">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
</div>

<script>
function myFunction() {
  document.getElementById("myDIV").style.columnFill = "balance";
}
</script>

</body>
</html>

The columnFill property specifies how to fill columns, balanced or not.

Property Values

Value Description
balance Default. Columns are balanced. Browsers should minimize the variation in column length
autoColumns are filled sequentially, and they will have different lengths
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

The columnFill property returns a String representing the column-fill property of an element.




PreviousNext

Related