Understanding the concept of flexbox
has been a challenge for me as I try to learn. My goal is to create a list of emails, where each item is a flexbox container (see below).
https://i.sstatic.net/2s4YZ.png
Guidelines:
- The tag is optional, but if shown, it appears directly next to the name.
- The date is always included, with varying width.
- The name of the person occupies the remaining space and is truncated if too long.
- There is a 5px gap between the name and the tag.
- The email subject is displayed on a new line and also truncated.
Check out my current progress here: https://jsbin.com/sepobipiwa/edit?html,css,output
.container {
width: 350px;
background-color: #FFF;
}
html {
font-family: 'Nunito Sans', sans-serif;
}
ul {
list-style-type: none;
padding: 0;
margin: 0;
}
li {
display: flex;
flex-direction: row;
align-items: baseline;
padding: 20px;
border-bottom: 1px solid #ccc;
}
.name {
font-size: 16px;
font-weight: bold;
text-overflow: ellipsis;
}
.tag {
margin-left: 5px;
font-size: 10px;
font-weight: bold;
background-color: #EFEFEF;
padding: 3px 5px;
border-radius: 3px;
text-transform: uppercase;
}
.subject {
font-size: 15px;
font-weight: 300;
color: #888;
text-overflow: ellipsis;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link href="https://fonts.googleapis.com/css?family=Nunito+Sans:300,400,600,700,800" rel="stylesheet">
<title>JS Bin</title>
</head>
<body>
<div class="container">
<ul>
<li>
<div class="name">John Doe</div>
<div class="date">14:50</div>
<div class="subject">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
</li>
<li>
<div class="name">Marrie Antoinette</div>
<div class="tag">Concept</div>
<div class="date">16:01</div>
<div class="subject">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
</li>
<li>
<div class="name">Someone with a long name</div>
<div class="tag">tag</div>
<div class="date">18:50</div>
<div class="subject">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
</li>
<li>
<div class="name">Someone with a long name</div>
<div class="tag">concept</div>
<div class="date">yesterday</div>
<div class="subject">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
</li>
</ul>
</div>
</body>
</html>