Note that there are some explanatory texts on larger screens.

plurals
  1. POHorizontal centering of div within display:table row
    primarykey
    data
    text
    <p>I have a layout composed of divs displaying as table, 3 table rows, and up to 5 table cells per row. My problem is twlofold: 1) I can't figure out how to center the table cells within the rows if there are less than five cells in the table., and 2) I can't figure out how to keep the integrity of the shapes when there are less than 5 in a row.</p> <p>The number of cells in a row will be variable (between 3 and 5), and I have to use divs -- I can't use real tables.</p> <p>Here is a codepen: <a href="http://codepen.io/Jaemaz/full/aCboe" rel="nofollow noreferrer">http://codepen.io/Jaemaz/full/aCboe</a></p> <p>Here is the source:</p> <p><strong>HTML:</strong></p> <pre><code>&lt;div class="focus-container"&gt; &lt;div class="focus-row"&gt; &lt;div class="focus-element circle"&gt; &lt;span class="ng-scope"&gt; Option A &lt;/span&gt; &lt;/div&gt; &lt;div class="focus-element circle"&gt; &lt;span class="ng-scope"&gt; Option B &lt;/span&gt; &lt;/div&gt; &lt;div class="focus-element circle"&gt; &lt;span class="ng-scope"&gt; Option C &lt;/span&gt; &lt;/div&gt; &lt;div class="focus-element circle"&gt; &lt;span class="ng-scope"&gt; Option D &lt;/span&gt; &lt;/div&gt; &lt;div class="focus-element circle"&gt; &lt;span class="ng-scope"&gt; Option E &lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="focus-row"&gt; &lt;div class="focus-element circle" ng-class="{unknown: unknown, square: square, circle: circle, selected: selected, shouldHaveBeenSelected: shouldHaveBeenSelected, shouldNotHaveBeenSelected: shouldNotHaveBeenSelected}" ng-click="click()" ng-transclude="" focuschoice="" identifier="F" enabled="true"&gt; &lt;span class="ng-scope"&gt; Option F &lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>CSS:</p> <pre><code>.focus-container { width: 560px; height: auto; display: table; background-color: #000; border-spacing: 15px; table-layout: fixed; -moz-user-select: none; -khtml-user-select: none; -webkit-user-select: none; user-select: none; } .focus-row { width: 100%; height: 100%; display: table-row; } .focus-element { width: 90px; height: 90px; display: table-cell; color: #fff; background: #808080; border: 2px solid #BFBFBF; vertical-align: middle; text-align: center; font-family: "Ubuntu", Arial, Helvetica, sans-serif; font-size: 14px; text-shadow: 0px 2px 1px rgba(0, 0, 0, 1); max-width: 94px; } .focus-element.circle { -moz-border-radius: 94px; -webkit-border-radius: 94px; border-radius: 94px; } </code></pre> <p>Screen Shot: <img src="https://i.stack.imgur.com/e4LR4.jpg" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload