Skip to content

Instantly share code, notes, and snippets.

@davorbadrov
Created November 4, 2015 18:29
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 davorbadrov/b8293e4ecf3a3d309191 to your computer and use it in GitHub Desktop.
Save davorbadrov/b8293e4ecf3a3d309191 to your computer and use it in GitHub Desktop.
Responsive elements with dynamic content using table styling.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="bar-container">
<div class="bar"></div>
<div class="time">00:20</div>
</div>
<div class="bar-container">
<div class="bar"></div>
<div class="time">01:00:20</div>
</div>
</body>
</html>
.bar-container {
padding: 5px 10px;
background: cornflowerblue;
margin-bottom: 5px;
display: table; /* use the table property for dynamic width allocation */
width: 100%;
}
.bar, .time {
display: table-cell;
}
.bar {
width: 100%; /* the bar will take all the available space */
background: coral;
}
.time {
padding: 0 5px; /* set some padding for the time */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment