Issue
I'm trying to create a simple grid-based ASCII graphics system in HTML.
The system interprets an array of single-character strings as a grid, with regular partitions representing rows.
These rows are then appended to some parent via a DIV
or P
container.
Aside from negative margins, how can I stylize this so that the distance between rows and columns are the same?
Here's what I've tried so far:
.grid {
display: flex;
flex-direction: column;
row-gap: 0px;
font-family: monospace;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="grid">
<div>XXXX</div>
<div>XXXX</div>
<div>XXXX</div>
<div>XXXX</div>
</div>
</body>
</html>
To be clear, I need the characters to sit flush against each other.
Solution
One way would be to set line-height
to the width of the character (8px
):
.grid {
display: flex;
flex-direction: column;
font-family: monospace;
line-height: 8px;
}
<div class="grid">
<div>XXXX</div>
<div>XXXX</div>
<div>XXXX</div>
<div>XXXX</div>
</div>
Answered By - Obsidian Age
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.