Align the SPAN and UL elements vertically

Take a look at this HTML snippet (Example):

<span>Sign in with</span>
<ul>
  <li><a href="#"><i class="icon-facebook"></i></a></li>
  <li><a href="#"><i class="icon-twitter"></i></a></li>
</ul>

Now, let's examine the corresponding CSS:

span {
  display: inline-block;
  font-weight: bold;
  margin-right: 6px;
}

ul {
  display: inline-block;
  list-style: none;
  list-style-type: none;
  margin: 0;
  padding: 0;
}

ul li {
  display: inline-block;
  list-style: none;
  list-style-type: none;
  margin: 0;
  padding: 4px;
}

ul li {
  font-size: 2.0rem;
}

The challenge here is aligning the SPAN vertically with the Icons in the UL. Despite trying different approaches like adding padding to span, the desired alignment remains elusive.

If you have any insights or solutions to share, please feel free to contribute!

Answer №1

To center your icons vertically, add vertical-align:middle to your <i> elements:

span {
  display: inline-block;
  font-weight: bold;
  margin-right: 6px;
}
ul {
  display: inline-block;
  list-style: none;
  list-style-type: none;
  margin: 0;
  padding: 0;
}
ul li {
  display: inline-block;
  list-style: none;
  list-style-type: none;
  margin: 0;
  padding: 4px;
}
ul li {
  font-size: 2.0rem;
}
i[class^="icon-"] {
  vertical-align: middle;
}
<link href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet" />
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet" />
<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet" />

<span>Sign in with</span>
<ul>
  <li><a href="#"><i class="icon-facebook"></i></a>
  </li>
  <li><a href="#"><i class="icon-twitter"></i></a>
  </li>
</ul>

Answer №2

Give this a shot

Check it out:

 <p>Login using</p>
    <ul>           
         <li><a href="#"><i class="icon-google"></i></a></li>
         <li><a href="#"><i class="icon-linkedin"></i></a></li>
     </ul>

Answer №3

give this a shot,

span {
  display: inline-block;
  font-weight: normal;
  margin-right: 9px;
  vertical-align:middle; /* included */
}

ul {
  display: inline-block;
  list-style: none;
  list-style-type: none;
  margin: 0;
  padding: 0;
  vertical-align:middle;  /* included */
}

ul li {
  display: inline-block;
  list-style: none;
  list-style-type: none;
  margin: 0;
  padding: 6px;
}

ul li {
  font-size: 2.5rem;
}

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

Python requests no longer retrieves HTML content

I am trying to extract a name from a public Linkedin URL using Python requests (2.7). Previously, the code was functioning correctly. import requests from bs4 import BeautifulSoup url = "https://www.linkedin.com/in/linustorvalds" html = requests.get(url ...

Displaying PHP output within a JavaScript expression

Let's dive into a scenario involving a basic HTML document and some JavaScript that's loaded within it: <!-- doc.html --> <!doctype html> <html lang="en"> <head> <script type="text/javascript" src=" ...

Experiencing issues with my website navigation malfunctioning on specific iOS devices

After testing my project today, I discovered that the mobile navigation on my website is not displaying its list items on certain iOS devices. The navigation worked fine on an iPhone 5 and iPad Mini, but failed to show the list items on an iPhone 4 and old ...

Mobile website menu selection

I want to create a select menu for my mobile website. I have added the select HTML code to my page. <select id="menu_mobile"> <option value="" selected="selected">Navigation</option> <option value="http://example.com/about"> Ab ...

Strange outcomes observed with CSS Selector nth-child

When utilizing the CSS nth-child selector, I am encountering some peculiar issues. The HTML structure is as follows: <div class="block feature-callout-c" id="overview"> <div class="row"> <div class="span twelve"> ...

What could be the reason that str_replace is failing to replace this particular string?

I am facing an issue with my PHP code that is intended to load data from a CSS file into a variable, find the old body background colour, replace it with a new colour submitted through a form, save the updated CSS file, and update the colour in a database. ...

I created a datatable that includes options for PDF and print functionality. Unfortunately, the images within the datatable are not displaying in either the PDF or print view

I created a data table with PDF and print buttons, but I am facing an issue where the images in the table are not visible in the PDF or print view. Although I have attached logos to the data table that are visible in the PDF and print view, the existing im ...

The multi-subrow feature in Material-UI tables does not support simultaneous hovering

I have integrated a table from material-ui into my project, similar to the image shown below: My issue is that when I hover over a specific row in the table, the background color changes to dark. However, some rows may contain sub-rows and I want these su ...

Struggling to incorporate JSON data and javascript functions into an HTML file

I've been struggling to create a feed from a json link and display it in separate divs within an html document. Despite multiple attempts with different approaches for three different newspaper sources, I have not been successful. I'm hoping som ...

CSS-Enabled Panels held in place with Draggable Feature

Currently immersed in my first ASP.net/HTML/CSS Application, I am exploring the realm of draggable panels using the Ajax-Control-Toolkit. So far, it's been a successful endeavor as I have managed to implement a single panel into my application! As de ...

The Image Slider functions smoothly in Chrome, but encounters issues in IE11

Here is a link to the code I've been working on: http://jsfiddle.net/wf32jbhx/ I attempted to host images on my SharePoint site, but they ended up stacking on top of each other instead of formatting properly. Oddly enough, everything appears fine in ...

Customize the style based on the state using styled components

I am currently working with a function component that looks like this: const Navbar = ({setNav, nav}) => { const [justify, setJustify] = useState('space-around') //get localStorage const user = JSON.parse(localStorage.getItem('user& ...

What is the best way to anchor floating labels in React while incorporating Tailwind CSS?

I am currently working on developing a registration form using React and Tailwind CSS. As part of this project, I have implemented a feature where the label slides up when an input form is focused. Everything seems to be working fine up to this point. Howe ...

Tips for Validating Radio Buttons in Angular Reactive Forms and Displaying Error Messages upon Submission

Objective: Ensure that the radio buttons are mandatory. Challenge: The element mat-error and its content are being displayed immediately, even before the form is submitted. It should only show up when the user tries to submit the form. I attempted to use ...

Why is the line height dimension missing from my model box when padding and margin are both set to 0?

I'm currently working on a project involving CSS/HTML and using Bootstrap 4 for my layout. I have a menu where I want the boxes to be the same size as the font-size, so I've set the margin and padding to 0. .menu-ppal { display: inline; li ...

Struggling to override a css element in a responsive design

Here is a Link that I am having trouble with. Within my CSS, I have an element named tbox. It functions as an inline box with a width set at 100%. On the homepage, it adjusts its width perfectly based on its parent and is fully responsive. However, when na ...

Creating a QR code with a logo using Python

Looking to add a logo in the center of a QR code for a project. Any tips or suggestions on how to achieve this? view image here Currently using django-qr-code to generate standard text QR codes, but now seeking to customize with a logo placed at the cent ...

Tips for retrieving the primary key of the highlighted row in bs_grid

I've integrated bs_grid to showcase a lineup of company names, each associated with a unique GUID identifier. Here's how I've set up the grid: $(function() { $('#grid1').bs_grid({ ajaxFetchDataURL: 'CompaniesList.asmx/G ...

What is a simple way to center a box on a page without relying on margins?

I'm attempting to position a box in the center of the page without relying on margin. Here's what I've tried so far: .box-middle { vertical-align:middle; height:100px; width:100px; border:1px solid #ddd; } This approach h ...

I desire to place a picture atop a carousel within a bootstrap framework

I'd like half of my display picture to overlap the carousel image at the top and be centered. The carousel should serve as a cover page similar to Facebook. .dp-container{ width: 200px; height: 200px; border: 2px solid black ...