Reputation: 79
Is there a way to have two spans on the same line so that:
You see in the code below that (2) and (3) are problematic because they don't take all available space.
Thanks in advance!
.box {
border: solid 1px #444;
padding: 5px;
font-family: sans-serif;
}
li {
white-space: nowrap;
font-size: 16px;
border: solid 1px #def;
padding: 0.5em;
background: #dfefff;
margin-bottom: 0.5em;
}
span {
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
}
.name {
color: #259;
}
.email {
color: #581;
}
.name,
.email {
max-width: 50%;
}
<div class="box">
<ol>
<li><span class="name">Demetrius Washington Montgomery McGollinghgrahham</span>
<span class="email">[email protected]</span>
</li>
<li><span class="name">James</span>
<span class="email">[email protected]</span>
</li>
<li><span class="name">Demetrius Washington Montgomery McGollinghgrahham</span>
<span class="email">[email protected]</span>
</li>
</ol>
</div>
Upvotes: 2
Views: 521
Reputation: 1101
I did 2 changes in your code. Added a display property to the <li>
to flexbox. change the max-width
of the .name, .email
from 50%
to 100%
. Please see the updated code below.
li {
white-space: nowrap;
font-size: 16px;
border: solid 1px #def;
padding: 0.5em;
background: #dfefff;
margin-bottom: 0.5em;
display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */
display: -ms-flexbox; /* TWEENER - IE 10 */
display: -webkit-flex; /* NEW - Chrome */
display: flex;
}
.email {
color: #581;
margin-left:5px;
}
.name,
.email {
max-width: 100%;
}
See the Demo
Upvotes: 1