Skip to content

Instantly share code, notes, and snippets.

@awayken
Created March 4, 2013 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awayken/5086424 to your computer and use it in GitHub Desktop.
Save awayken/5086424 to your computer and use it in GitHub Desktop.
Design From the Inside Out With CSS Min-Content
/**
* Design From the Inside Out With CSS Min-Content
* http://demosthenes.info/blog/662/Design-From-the-Inside-Out-With-CSS-MinContent
*/
figure {
border: 2px solid black;
background: #cae9b8;
margin: 0 auto 1em auto;
}
figure.mincontent {
width: -moz-min-content;
width: -webkit-min-content;
width: -ms-min-content;
width: -o-min-content;
width: min-content;
}
figcaption, p {
text-align: center;
margin: 1rem;
}
figcaption {
font-weight: bolder;
font-size: 1.2rem;
}
<figure>
<img src="http://placekitten.com/400/200" alt="Cat picture. Durr.">
<figcaption>Cat (inherent width)</figcaption>
<p>A photo taken by Thomas Hawk on April 18, 2010 using a Canon EOS 5D Mark II.</p>
</figure>
<figure class="mincontent">
<img src="http://placekitten.com/400/200" alt="Cat picture. Durr.">
<figcaption>Cat (min-content width)</figcaption>
<p>A photo taken by Thomas Hawk on April 18, 2010 using a Canon EOS 5D Mark II.</p>
</figure>
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment