|
It's a real PITA just centering an element in CSS, but this is something entirely different
This is just next level masochism
|
|
|
|
|
Didn't you know CSS stands for: Crying Stinking Shame
|
|
|
|
|
|
Sander Rossel wrote: It's a real PITA just centering an element in CSS
Not since flexbox[^] and grid[^] are widely supported. Even vertical centering is fairly trivial now.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
For some reason I'm having a really hard time believing anything is easy in CSS...
Although I could brush up on my CSS skills a bit.
|
|
|
|
|
.center-me {
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
} Edit fiddle - JSFiddle[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm amazed, but I'm remaining skeptic.
CSS has a lot of trust to rebuild before we can be friends again
|
|
|
|
|
As amazing as that is, it's basically just vector art. The same thing could be done using svg.
|
|
|
|
|
OK, reformatted to protect the guilty.
Write a function in your favorite language to create a "day view" in an array for a month, like 11/2019. So for that month/year, the array should look like this, where the day numbers not in the month are null or undefined:
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
My solution in C#, which uses an extension method:
int?[] days = new int?[6 * 7];
var dow = (int)new DateTime(2019, 11, 1).DayOfWeek;
Enumerable.Range(1, DateTime.DaysInMonth(2019, 11)).ForEachWithIndex((idx, n) => days[dow + idx] = n); And the output function:
days.ForEachWithIndex((idx, n) => Console.Write(((idx % 7 == 0) ? "\r\n" : "") + (n?.ToString()?.PadLeft(5) ?? " "))); Which of course generates a leading CRLF, but oh well, that wasn't specifically indicated not to do so in the spec.
For the curious, this came up in a conversation with a coworker.
modified 5-Nov-19 14:41pm.
|
|
|
|
|
Is this your homework, sonny.
A Fine is a Tax for doing something wrong
A Tax is a Fine for doing something good.
|
|
|
|
|
RossMW wrote: Is this your homework, sonny.
Urgentz! Help PLZ!!!
|
|
|
|
|
Ok, completely not familiar with this stuff, but would ((idx % 7 == 0) && (idx > 0)) ? not prevent from a leading space?
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
0x01AA wrote: && (idx > 0))
Exactly what I was thinking, I just figured I'd show you what I'd come up with, warts and all.
|
|
|
|
|
Now make it work for cultures whose week doesn't start on Sunday.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: cultures whose week doesn't start on Sunday. That's easy - NUKE 'EM !
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
|
Not at all - as a humanitarian, I prefer to make in quick and painless.
. . . at least I won't feel a thing . . .
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Richard Deeming wrote: Now make it work for cultures whose week doesn't start on Sunday.
I wonder if there are any cultures that don't have a 7 day week? Or even the concept of a week?
|
|
|
|
|
|
For bonus points, on the management/sales side:
- convince a culture with a different week size to adopt the 7 days week.
- convince a culture without the concept of calendar to adopt a 10 days week calendar (or 5 day, for the impatient), and then apply previous step.
|
|
|
|
|
Took this a step further and extended the code, and it should work with culture:
void Main()
{
StringBuilder builder = new StringBuilder();
Enumerable.Range(1, 12)
.ToList()
.ForEach(e => PopulateDayOfMonth(2021, e, builder));
Console.WriteLine(builder.ToString().Trim());
}
static void PopulateDayOfMonth(int year, int month, StringBuilder builder)
{
builder.AppendLine();
int space = 6;
int dashLine = 1 + (space * 7);
IEnumerable<DateTime> days = Enumerable.Range(1, DateTime.DaysInMonth(year, month))
.Select(d => new DateTime(year, month, d));
builder.AppendLine(days.First().ToString("MMMMM"));
builder.Append('-', dashLine);
builder.AppendLine();
builder.AppendLine($"|{string.Join("|", Enum.GetNames(typeof(DayOfWeek)).Select(d => $" {d.Substring(0, 3)} "))}|" );
builder.Append('-', dashLine);
builder.AppendLine();
DayOfWeek dow = days.First().DayOfWeek;
while (dow != 0)
{
builder.Append(' ', space);
dow--;
}
bool first = true;
foreach (var d in days)
{
if (!first && d.DayOfWeek == 0)
{
builder.AppendLine("|");
builder.Append('-', dashLine);
builder.AppendLine();
}
builder.Append($"|{d.Day.ToString().PadLeft(space - 2)} ");
first = false;
}
builder.AppendLine("|");
builder.Append('-', dashLine);
builder.AppendLine();
}
With the following output:
January
-------------------------------------------
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
-------------------------------------------
| 1 | 2 |
-------------------------------------------
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
-------------------------------------------
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
-------------------------------------------
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
-------------------------------------------
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
-------------------------------------------
| 31 |
-------------------------------------------
February
-------------------------------------------
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
-------------------------------------------
| 1 | 2 | 3 | 4 | 5 | 6 |
-------------------------------------------
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
-------------------------------------------
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
-------------------------------------------
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
-------------------------------------------
| 28 |
-------------------------------------------
March
-------------------------------------------
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
-------------------------------------------
| 1 | 2 | 3 | 4 | 5 | 6 |
-------------------------------------------
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
-------------------------------------------
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
-------------------------------------------
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
-------------------------------------------
| 28 | 29 | 30 | 31 |
-------------------------------------------
April
-------------------------------------------
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
-------------------------------------------
| 1 | 2 | 3 |
-------------------------------------------
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
-------------------------------------------
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
-------------------------------------------
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
-------------------------------------------
| 25 | 26 | 27 | 28 | 29 | 30 |
-------------------------------------------
May
-------------------------------------------
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
-------------------------------------------
| 1 |
-------------------------------------------
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
-------------------------------------------
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
-------------------------------------------
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
-------------------------------------------
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
-------------------------------------------
| 30 | 31 |
-------------------------------------------
June
-------------------------------------------
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
-------------------------------------------
| 1 | 2 | 3 | 4 | 5 |
-------------------------------------------
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
-------------------------------------------
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
-------------------------------------------
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
-------------------------------------------
| 27 | 28 | 29 | 30 |
-------------------------------------------
July
-------------------------------------------
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
-------------------------------------------
| 1 | 2 | 3 |
-------------------------------------------
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
-------------------------------------------
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
-------------------------------------------
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
-------------------------------------------
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
-------------------------------------------
August
-------------------------------------------
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
-------------------------------------------
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
-------------------------------------------
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
-------------------------------------------
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
-------------------------------------------
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
-------------------------------------------
| 29 | 30 | 31 |
-------------------------------------------
September
-------------------------------------------
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
-------------------------------------------
| 1 | 2 | 3 | 4 |
-------------------------------------------
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
-------------------------------------------
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
-------------------------------------------
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
-------------------------------------------
| 26 | 27 | 28 | 29 | 30 |
-------------------------------------------
October
-------------------------------------------
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
-------------------------------------------
| 1 | 2 |
-------------------------------------------
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
-------------------------------------------
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
-------------------------------------------
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
-------------------------------------------
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
-------------------------------------------
| 31 |
-------------------------------------------
November
-------------------------------------------
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
-------------------------------------------
| 1 | 2 | 3 | 4 | 5 | 6 |
-------------------------------------------
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
-------------------------------------------
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
-------------------------------------------
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
-------------------------------------------
| 28 | 29 | 30 |
-------------------------------------------
December
-------------------------------------------
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
-------------------------------------------
| 1 | 2 | 3 | 4 |
-------------------------------------------
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
-------------------------------------------
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
-------------------------------------------
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
-------------------------------------------
| 26 | 27 | 28 | 29 | 30 | 31 |
-------------------------------------------
|
|
|
|
|
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
Unfortunately, that still assumes the first day of the week is Sunday.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sunday is part of the weekend. That's a clue as to the correct day that a week starts on
|
|
|
|
|
Member 11005478 wrote: weekend. That's a clue as to the correct day that a week starts on Just like bookends are all on one side.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|