Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <p>Normally, the table takes up the space it needs. If you give the `table` a 100% width, it will take 100% of the with and share that between the cells regarding their contents.</p>

<p>There is no such thing as <em>free space in a table</em>: at some point, there must be a cell that takes up the remaining space once the size of the others have been set.</p>

<p>To set a width of a cell, you would need to give it a `width` and a `max-width` to the same size.<br/>
For a table with N columns, you can do that to N-1 columns, and the remaining column will take the remaining space.</p>

<p>If you do that to N-2 columns, the two columns that do not have fixed with will share the remaining space.</p>

<p>Having this all, you can add `white-space:no-wrap` and/or `text-overflow:ellipsis` if you wish.</p>

<table>
	<thead>
		<tr>
			<th>30px</th>
			<th>150px</th>
			<th>auto (remaining space)</th>
			<th>auto (min)</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td><img src="https://picsum.photos/30/30/?random&1"></td>
			<td>genus hoc scribendi</td>
			<td>Non eram nescius, Brute, cum, quae summis ingeniis exquisitaque doctrina philosophi Graeco sermone tractavissent, ea Latinis litteris mandaremus</td>
			<td>lorem ipsum</td>
		</tr>
		<tr>
			<td><img src="https://picsum.photos/30/30/?random&2"></td>
			<td>vituperata ab Hortensio. qui liber cum et tibi probatus videretur et iis, quos ego posse iudicare arbitrarer, plura text</td>
			<td>vituperata ab Hortensio. qui liber cum et tibi probatus videretur et iis, quos ego posse iudicare arbitrarer, plura</td>
			<td>lorem ipsum dolor</td>
		</tr>
		<tr>
			<td><img src="https://picsum.photos/30/30/?random&3"></td>
			<td>quam his</td>
			<td>etenim si delectamur</td>
			<td>lorem ipsum</td>
		</tr>
		<tr>
			<td><img src="https://picsum.photos/30/30/?random&4"></td>
			<td>etiam sapientia</td>
			<td>etenim si delectamur, cum scribimus, quis est tam invidus, qui ab eo nos abducat? sin laboramus, quis</td>
			<td>lorem ipsum</td>
		</tr>
		<tr>
			<td><img src="https://picsum.photos/30/30/?random&5"></td>
			<td>Lucilius, recusabo, quo minus omnes mea</td>
			<td>am si dicent ab illis has res esse tractatas, ne ipsos quidem Graecos est cur tam multos legant, quam legendi sunt. quid enim est a Chrysippo praetermissum in Stoicis? legimus tamen Diogenem, Antipatrum, Mnesarchum, Panaetium, multos alios in primisque familiarem</td>
			<td>lorem ipsum</td>
		</tr>
		<tr>
			<td><img src="https://picsum.photos/30/30/?random&6"></td>
			<td>Graecis isdem de</td>
			<td>Ego</td>
			<td>lorem ipsum</td>
		</tr>
	</tbody>
</table>

<p>In this example:</p>
<ul>
	<li>The first to cells are fixed width no matter what. The contents adapts to it. You can add text or resize the browser, it keeps its size.</li>
	<li>The third cell is flexible. It grows and shrinks with the browser / container / windows, but the text still adapts to it.</li>
	<li>The last cell is flexible. It grows and shrinks with its contents only</li>
</ul>
              
            
!

CSS

              
                table {
	width: 100%;
	background-color: white;
}

td {
	padding: 10px;
	max-width: 0; /* avoids long text overflowing from <table> */
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	background-color: silver;
}

/* The cell will be 30px wide (+paddings) */
td:first-of-type {
	width: 30px;
	max-width: 30px;
}

/* The cell will be 150px wide (+paddings) */
/* overflowing text will be "ellipsed" */
td:nth-of-type(2) {
	width: 150px;
	max-width: 150px;
}

/* this cell takes the remainint width */
/* no specific max-width here : it’s already declared in the “td{}” */
td:nth-of-type(3) {
	width: auto;
}

/* this allows a cell to fit the size of the content */
/* the size of the collumn, actually, will be that of the largest content in that collumn */
td:nth-of-type(4) {
	width: 0;
	max-width: 100%;
}


              
            
!

JS

              
                
              
            
!
999px

Console