Words not within the span, away from the span border

I’m currently in the process of creating a dedicated section on my website called "Voices of the Nation,” which draws inspiration from the foundations laid out in the U.S. Constitution. The objective is to highlight individuals who have shown their support for this initiative by acting as digital “signers.” One challenge I am facing involves displaying these names with varying font sizes in an aesthetically pleasing manner on the webpage. It seems that there is some inconsistency regarding the alignment of the text within the spans containing the names. Here are a couple of visuals illustrating the issue:

https://i.sstatic.net/GR4EP.jpg

Upon closer inspection, you can observe that certain names overlap each other, which is something I would like to rectify. An interesting observation is that the text appears to be positioned outside the outlines of the span elements:

https://i.sstatic.net/TLUvS.jpg

A similar discrepancy can be spotted across all the listed names. Below is a snippet of the HTML code I am using:

<div id="names">   
    <span class="order ten CalifornyaA-Bold" id="o3">Eric So</span> &nbsp;
    <span class="order twenty-five CalifornyaB-Bold" id="o5">Sierra Hansen</span> &nbsp;
    <span class="order ten CalifornyaB-Bold" id="o6">Eleanor Collier</span> &nbsp;
    ...
    <span class="order twenty-five CalifornyaC-Bold" id="o69">Maeve McCarty</span> &nbsp;
</div>

... along with the corresponding CSS styling:

#names {
  text-align: center;
  padding-bottom: 10%;
}
.hancock, .five-hundred, .two-hundred, .one-hundred, .fifty, .twenty-five, .ten {
  line-height: 1.5em;
  white-space: nowrap;
}
.hancock {
  font-size: 5.5em;
}
.five-hundred {
  font-size: 4em;
}
.two-hundred {
  font-size: 3.4em;
}
.one-hundred {
  font-size: 2.8em;
}
.fifty {
  font-size: 2.2em;
}
.twenty-five {
  font-size: 1.6em;
}
.ten {
  font-size: 1em;
}

If anyone could offer assistance or guidance on resolving this issue, I would be extremely grateful!

Answer №1

Consider adjusting the line-height property for these inline elements instead of block elements:

.hancock, .five-hundred, .two-hundred, .one-hundred, .fifty, .twenty-five, .ten {
      line-height: 110%;//percent would be good
      white-space: nowrap;
    }

You can also set individual CSS rules for each element rather than setting all to 1.5em
Edit:
Make sure to specify a font-size for the parent element when using em units. Take a look at how I wrapped text and added a font-size in em on this page without any overlapping: https://i.sstatic.net/CUzKx.png

Answer №2

utilize the following code snippet:

span {line-height: 1.2;}

Answer №3

Using display: inline-block along with adjusting the margin-top seems to do the trick quite effectively. While it may be considered a workaround, it does the job adequately.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible for me to create a CSS class based on a condition using [ngCLASS]?

I am struggling with logic writing in my Angular2 project. On a HTML page, I have two buttons - YES and NO that I want to style with different colors. I have set up a condition in the div tag like this: ngClass="'result'?'yes':' ...

How to address hover problems in D3.js when dealing with Path elements and updating tooltip information after brushing the focus

Seeking assistance with a Multi Series, Focus + Context D3 chart and hoping to address my main queries all at once. The questions that need resolving are: How can I prevent the tooltips I've generated from being affected by the hair-line (which t ...

Text overlapping image causing hover state interference

I'm feeling completely lost right now. My goal is to have the title of each project displayed in the center of the screen when you hover over the respective project images. I've resorted to using jQuery for this because it seems like the most str ...

Determine line-height and adjust positions using JavaScript in the Chrome browser

I am creating a basic text reading application with a line to aid in easy reading. The functionality involves using the up and down arrow keys on the keyboard to adjust the position of a red line based on the line-height property. This is accomplished thr ...

Retrieve the image source when clicking on multiple posts that share the same div class and button class

<script src="https://code.jquery.com/jquery-1.11.1.js"></script> <script> $(function(){ $('.like').click(function(e){ e.preventDefault(); // stop the page from reloading alert( $('.post-container&apos ...

Failure to Connect HTML with Stylesheet

Feeling a bit lost here. I've been attempting to connect my homepage to my stylesheet, but no matter how often I refresh the page, it just won't recognize the link. I'm diligently following the instructions from the guide I have, copying and ...

Can someone explain why my table in Laravel is only showing the third set of data and not the others?

I'm facing an issue with displaying all of the data in my table named taglineImageCarousel. The problem lies in the slide_ID column, where it is being populated with data from slide-01, slide-02, and slide-03. Below is the code snippet: taglineImage ...

What is the best way to make three divs that can be adjusted in size?

Desired Layout: | A | | B | | C | ^ ^ Adjustment Behavior: | A | | B | | C | Current Issue: | A | C | I attempted to enhance the functionality by modifying the provided JavaScript cod ...

Guide on using a while-loop in selenium with python to continuously run until a specific element is no longer present on the page

I'm currently facing a challenge with creating a while-loop that will run until a specific element is no longer present on a website. My existing solution gets the job done, but I know there's room for improvement. I would love to hear suggestion ...

Apply pointer style to the CSS only when a division contains text

If there is plain text inside a div with class="x95qze", how can we add cursor:pointer only to the second div that contains the text Cursor pointer required here. The div with class="x95qze" will not change. The content of the div may ...

"Skip the inbox clutter and access the compose page directly on Gmail, Yahoo, and

I was looking to create a unique hyperlink that would direct users to a compose page similar to Google Mail. Here is an example of what I tried: <li><a href="https://inbox.google.com/mail/?view=cm&fs=1&<a href="/cdn-cgi/l/email-protect ...

Using App Storage on Windows Phone 8 with HTML5

Exploring storage options for my html5 app compatible with both windows 8 and windows phone 8. Considering: Local Storage IndexDB Looking for advice on the best storage mechanism to use. Is IndexDB compatible with windows phone 8? Any insights on quota ...

What is the best way to manage selected checkboxes in PHP?

Could you please assist me with a problem I am facing? I have a form where users can select checkboxes, but I'm struggling to display the selected checkbox item names in the result. Currently, my HTML site is using the value attribute to calculate the ...

Unable to move up and down in my iframe

I am currently working on an Instagram page that is visible through an iframe. Everything seems to be functioning fine on my iMac, but I am facing an issue with scrolling on my iPhone and iPad? After reviewing my code, I couldn't find any hidden over ...

Animate owlCarousel slide motion in reverse when using the Prev and Next buttons

The default functionality of owlCarousel is to move to the right when clicking Next and to the left when clicking Prev. However, after applying animations, both directions always move in the same direction. Check out this sample on jsfiddle to see the iss ...

Update the class of the panel immediately prior to a click event

Is it possible to change the class before the animation starts or when opening/closing the panel? Currently, the class only changes after the animation has finished and the panel is already open or closed. Here is an example: http://jsfiddle.net/0b9jppve/ ...

Finding the nearest span value upon clicking through a specific class

Whenever a user clicks on a hyperlink, my goal is to locate the nearest span element with a specific class and retrieve the text within that class. As of now, it is only returning blank text: Here is the provided HTML code snippet: <div class="plan re ...

Change all instances of the asterisk character to a red color on every page using CSS styling

Is it possible to change the color of the asterisk that indicates required fields on all forms across my site without having to wrap it in a div or another wrapper? ...

Acquire the current audio video stream directly from the web browser

Currently, I am utilizing a JavaScript library that internally invokes getUserMedia. My objective is to access the stream object that has already been initiated. Unfortunately, the library does not provide any means to retrieve it. Is there a method avai ...

Populate a map<object, string> with values from an Angular 6 form

I'm currently setting keys and values into a map from a form, checking for validation if the field is not null for each one. I am seeking a more efficient solution to streamline my code as I have over 10 fields to handle... Below is an excerpt of my ...