How do I align a span next to a series of images correctly?

Trying to align a span with an image background next to a list of images, but the span is appearing 40px below the images instead of right next to them.

My HTML code:

<div id="people">
    <img width="44" height="44" src="http://www.mysite.com/image.png" class="personImage" rel="/Person/CorpInfo/74" title="Name"> 

    <img width="44" height="44" src="http://www.mysite.com/image2.png" class="personImage" rel="/Person/CorpInfo/79" title="Name"> 

    <span class="initials" rel="/Person/CorpInfo/839" title="Name">YA</span>

    <img width="44" height="44" src="http://www.mysite.com/image3.png" class="personImage" rel="/Person/CorpInfo/49" title="Name"> 
 </div>

It seems that when displaying a list of images and occasionally a span with initials and a generic picture as background, the span is not lining up properly.

CSS for the "initials" span:

.initials 
{
 display: inline-block;
 font-size: 24px;
 vertical-align: middle;
 height: 44px;
 left: 0;
 top: 0;
 line-height: 44px;
 font-weight: 500;
 overflow: hidden;
 background: url('/content/Images/generic1small.png') no-repeat 0 0;
 text-align: center;
 width: 44px;
}

and CSS for the "personImage" class:

.personImage
{
   display:inline;
}

Tried using a hack to align them:

<style type="text/css">
    .initials {    margin: -40px 5px 0px 0px;}
</style>

However, this hack causes other issues on the page. Any suggestion on why the span is not aligning properly with the images?

Answer №1

Did you attempt to modify

.initials {
    vertical-align: bottom;
}

to

.initials {
    vertical-align: baseline;
}

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

Initiate a page break at the beginning of the table in case there are not enough lines on the first page

Does anyone know how to ensure that a table starts on a new page when printing, rather than continuing at the bottom of the previous page? I have tables with repeating headers and many rows, and sometimes a new table will start at the very end of a page. ...

Unable to adjust the dimensions of a Mailchimp input field

Having some trouble customizing my Mailchimp form a bit and could use some assistance. Snippet of the code: <!-- Begin MailChimp Signup Form --> <link href="//cdn-images.mailchimp.com/embedcode/horizontal-slim-10_7.css" rel="stylesheet" type=" ...

Prevent tooltips from disappearing when hovering over them

I need assistance in keeping my tooltip visible when the mouse is on it, but hiding it when the mouse moves out. Can you please help me achieve this? $(document).ready(function(){ $('[rel=tooltip]').bind('mouseover', function() { ...

Is there a way to present a standard image in a circular format?

My goal is to transform a regular rectangle image into a rounded image. Can anyone provide guidance on how to achieve this transformation? (Credit for the image) ...

JQuery may be successfully loaded, but it is not functioning as intended

Just started dabbling in JQuery (I'm a newbie) but I'm having trouble getting it to work! Initially, it worked a couple of times but then suddenly stopped working (pretty strange). I made some changes and now it doesn't work at all. JQuery a ...

Set a background image URL for a specific division inside a template

I have a drawPlaceDetails function that populates an HTML template with values. The getPhotoURL() function retrieves a URL link to an image, which I am trying to assign to the background-image property. However, the div remains empty without displaying the ...

Locate a specific sub-tag once you have retrieved an array containing all of the parent tags

I have a list of elements, each containing nested elements like this: <span> <span> <img /> <a /> <b /> </span> </span> There are additional data within these elements, but I canno ...

Issues with Alignment of Navbar Elements in Bootstrap 3

When I test my website locally, the elements are aligned correctly as expected. However, when I view it on my live webpage, the elements are all left-aligned. I've attempted a solution from this source, but the issue persists. What confuses me is why ...

Style the input element for typeahead functionality

I am working on a simple textbox input that has the following appearance: <input type="text" placeholder="Search for states"> My goal is to implement an autocomplete feature similar to typeahead. While I have successfully implemented the autocomple ...

Issue with CSS styles not linking correctly to ejs templates

I'm having trouble linking my CSS stylesheet in my project. I have the CSS file stored in a public folder with a css subfolder within it. Despite trying various methods, I can't seem to get the stylesheet to connect properly. Below is a snippet f ...

Ways to define a variable based on a CSS class attribute?

I need help figuring out how to create a variable in my script that is defined by the width attribute of a CSS class. The snippet I have currently doesn't seem to work as expected. var dist = $('.nav').css(width()); The goal of my script i ...

How to efficiently display information from a MySQL database onto textboxes using AJAX, and successfully repeat the process within the same PHP webpage

How can I retrieve and display data in textboxes from a MySQL database using Ajax, specifically when needing to do so twice within the same form in PHP? The first database table, names, includes: guid id name 1 101 ...

When the position of my navbar is set to fixed, it doesn't stay attached to the top of the webpage

Currently, I am working on programming a website and I am trying to create a navigation bar that stays fixed at the top while scrolling. I have attempted to achieve this using the following CSS: h1 { Position: fixed; } However, the above code is not ...

The fixed navigation bar shows a flickering effect while scrolling at a slow pace

Currently facing a challenge with our sticky navigation. Noticing a flickering issue on the second navigation (sticky nav) when users scroll down slowly. The problem seems to be specific to Chrome and Edge, as it doesn't occur on Firefox, IE11, and S ...

Encountering difficulties in targeting a JavaScript generated button within an array using a function, resulting in an error message that reads "Unable to read property 'setAttribute' of null"

Trying to change the background of a specific button when clicking on it is proving to be quite the challenge for me. I created an array of 100 buttons (with the intention of developing a simple game later) using a for loop, giving each button a unique id ...

Guide to creating a scrollable container that occupies the remaining height of the screen

Looking to create a fixed container that is scrollable, while keeping the rest of the page fixed? Check out this Stackblitz example. Here's a component called "PageDefault" that includes a Header and wraps each page in the application (the content of ...

Tips for modifying padding in HTML and CSS?

I'm struggling to add padding around the image without affecting the mobile view. Here's what I've tried: float-right or padding-right:250px; // but nothing happens and it affects the mobile view. Please review my code: .fontProfile ...

sound not functioning on iPad

<audio id="example" controls="controls"> <source src="1.mp3" type="audio/mpeg" /> <source src="1.ogg" type="audio/ogg" /> </audio> JavaScript code to automatically play video when the page loads document.getElementById(&ap ...

Issue with local image on Vue.js slider causing malfunction

Hey, I came across this awesome Vue.js image slider on "digitalocean.com" but it seems to only work with images uploaded on platforms like imgbb, pixabay, etc. I tried to use a local image from my assets folder, but it's not working. Can anyone help m ...

How can I update the background color of the specified element when the text changes without triggering a postback?

Seeking guidance on JavaScript as I am not very adept in it. We have a webpage where users upload .XLS/.CSV files and review the data before submitting it to our database. Users can edit cells in the uploaded document on our "review" screen before final su ...