Your search did not match any results.
Box

Box

The Box component allows you to create layouts of any complexity. You can arrange multiple blocks (items) horizontally or vertically, specify relative or absolute block sizes, and nest layouts within each other.

Set the Box's width and height properties to specify the layout's overall dimensions. To add blocks, use the items array, the dataSource property, or specify dxItems in the markup.

This demo shows how to use the Box component to create three different layouts.

The first Box sets direction to row and thus arranges items horizontally. Items use the ratio property to set their width in relative units.

The second Box shows two additional features:

  • Items now use the baseSize property to set their width in pixels or percent.
  • The middle item contains a nested Box. The align and crossAlign properties make sure that the nested layout is centered within its container.

The third Box demonstrates a layout similar to a basic web page structure. The root layout sets direction to col and arranges its items vertically. The nested layout is arranged horizontally.

Backend API
Copy to CodePen
Apply
Reset
$(() => { $('.boxOptions1').dxBox({ direction: 'row', width: '100%', height: 75, }); $('#boxOptions2').dxBox({ direction: 'row', width: '100%', height: 75, align: 'center', crossAlign: 'center', }); $('#boxOptions3').dxBox({ direction: 'col', width: '100%', height: 250, }); $('#boxOptions4').dxBox({ direction: 'row', width: '100%', height: 125, }); });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/22.1.6/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/22.1.6/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/22.1.6/js/dx.all.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div class="boxOptions1"> <div class="rect demo-dark" data-options="dxItem: {ratio: 1}"> ratio = 1 </div> <div class="rect demo-light" data-options="dxItem: {ratio: 2}"> ratio = 2 </div> <div class="rect demo-dark" data-options="dxItem: {ratio: 1}"> ratio = 1 </div> </div> <br /> <div class="boxOptions1"> <div class="rect demo-dark" data-options="dxItem: {ratio: 0, baseSize: 150}"> 150px </div> <div class="demo-light" data-options="dxItem: {ratio: 1}"> <div id="boxOptions2"> <div data-options="dxItem: {ratio: 0, baseSize: 50}"> <div class="small"></div> </div> <div data-options="dxItem: {ratio: 0, baseSize: 50}"> <div class="small"></div> </div> <div data-options="dxItem: {ratio: 0, baseSize: 50}"> <div class="small"></div> </div> </div> </div> <div class="rect demo-dark" data-options="dxItem: {ratio: 0, baseSize: '10%'}"> 10% </div> </div> <br /> <div id="boxOptions3"> <div class="rect demo-dark header" data-options="dxItem: {ratio: 1}"> Header </div> <div data-options="dxItem: {ratio: 2, baseSize: 0}"> <div id="boxOptions4"> <div class="rect demo-dark" data-options="dxItem: {ratio: 1}"> Left Bar </div> <div class="rect demo-light" data-options="dxItem: {ratio: 1}"> Content </div> <div class="rect demo-dark" data-options="dxItem: {ratio: 1}"> Right Bar </div> </div> </div> <div class="rect demo-dark footer" data-options="dxItem: {ratio: 1}"> Footer </div> </div> </div> </body> </html>
.rect { text-align: center; font-size: 30px; padding-top: 10px; height: 100%; } .demo-light { background: rgba(245, 229, 166, 0.5); } .demo-dark { background: rgba(148, 215, 199, 0.5); } .demo-dark.header { background: rgba(243, 158, 108, 0.5); } .demo-dark.footer { background: rgba(123, 155, 207, 0.5); } .small { height: 50px; border: 1px solid lightgray; }