I have two types of event labels. The HTML markup is:
<article>
<time class="reg-day">Mo</time>
<time class="reg-time">13:00-14:30 Uhr</time>
<p class="reg-location">Regent Street</p>
</article>
<article>
<time class="work-month">Feb</time>
<time class="work-day">24</time>
<p class="work-type">Chess Group</p>
<p class="work-location">Moonshine Avenue</p>
</article>
And the CSS the question is about is:
article {
background-color: red;
width: 20em;
position:relative;
}
.reg-day {
position: absolute;
font-size:2.25em;
font-weight:700;
line-height:1.4;
left:.5em;
}
.reg-time,
.reg-location {
margin-left:5em;
line-height: 1;
}
.work-month {
-webkit-transform: rotate(270deg);
width:3em;
position: absolute;
text-align:center;
left:-1em;
bottom:1em;
font-weight:700;
}
.work-day {
position: absolute;
font-size:2.25em;
font-weight:700;
line-height:1.4;
left:.75em;
}
.work-type,
.work-location {
margin-left: 5em;
line-height: 1;
}
I have two types of event labels and have created a CodePen here.
The first one has the day on the left, the time on the upper right, and the location on the lower right.
The second has the month upright on the left, the day and on the upper right the type of event, and the location on the lower right.
Basically I've managed to get the layout as I wanted. Is the way I got there ok or is there a more robust and elegant one?
Especially the part of the day of week (of the first event type) and the day of month (of the second event type) covering more or less 2 height units of the two pieces of information on the right.
Day of week/day of month:
font-size: 3em;
line-height:1
Info:
font-size: 1em
line-height: 1.5;
would work. That the info lines are the exact half of the day of week / day of month. Also i am unsure if using position absolute is the correct weapon of choice in that case. At least it prevents an misalignment of the margin-left: 5em
elements. But over all the number of "magic numbers" feels a bit too high.