I have a csv file with list of names
ex:
MUSK Elon,LEE Brucen
GATES Bill,TRUMP Donaldn
and I am trying to print out names in different fonts, sizes, and spacings using html.
My goal is to print out something like this:
I tried this code for CSS:
.font:first-letter {
font-size: 150%;
}
but it didn’t give me what I wanted because it only affected the first letter of the whole line, not every entry separated by commas.
var fontSizeInput = document.getElementById("font-size-input");
var fontSize = fontSizeInput.value + "pt";
//... other inputs
var lines = text.split('n');
var container = document.getElementById('text-container');
container.innerHTML = '';
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
var p = document.createElement('p');
// Applying font style
p.className = 'font';
p.style.fontSize = fontSize;
// Replace comma with a space
var modifiedLine = line.replace(/,/g, ' ');
p.innerHTML += modifiedLine;
container.appendChild(p);
This is not everything but what I have so far regarding the font sizes. I am thinking separating the first letter before I append and applying a different font size but wondering if this is a good way and if there is a better way to do this.
Thank you I appreciate any help!
2
Answers
To do this you should probably make the names spans and do "first letter" of the span. I notice that the last name has a bigger font size than the last, so you could split it into classes. Try this for HTML:
Because spans are inline, they will stay on the same line (which is why there is a "br" tag.
For CSS:
Here is another way
Jquery
CSS
And the HTML
Give it a try or see it working in this codepen I created for you
https://codepen.io/Familia-Santiaborg/pen/GRwymwm