List arranged in order with a hyperlink in the center and an image positioned on the right side

I am trying to create an ordered list with a link to an article in the middle and a small png image file positioned directly to the right of it.

For reference, here is an image depicting the exact type of list that I am aiming to achieve: https://i.stack.imgur.com/UFyWs.png

The current code I have is almost there but requires some modifications. What adjustments should I make to my code to successfully implement this ordered list?

HTML

<div id ="most-emailed">
      <h2>MOST EMAILED</h2>
        <ol>
          <li>
            <a href="">Well: Writing Your Way To Happiness</a>
            <img src="images/well.jpg"/>
          </li>

          <li>
            <a href="">White House Proposals on 529 College Plans Would Reduce Benefits</a>
          </li><img src="images/silver.jpg"/>
          <li>
            <a href="">Well: Ask Well: The Benefits of a Lunch Hour Walk</a>
            <img src="images/physed.jpg"/>
          </li>
          <li>
            <a href="">Well: Ask Well: The Best Time of Day to Exercise to Lose Weight</a>
            <img src="images/morning.jpg"/>
          </li>
          <li>
            <a href="">Op-Ed Contributor: Why Adnan Syed of 'Serial' Should Have Pleaded Guilty</a>
            <img src="images/murray.jpg">
          </li>
          <li>
            <a href="">36 Hours in Denver</a>
            <img src="images/denver.jpg"/>
          </li>
          <li>
            <a href="">U.S Says Assembly Speaker Sheldon Silver Took Millions in Payoffs...</a>
            <img src="images/silver.jpg"/>
          </li>
          <li>
            <a href="">Paul Krugman: Much Too Responsible</a>
            <img src="images/krugman.png"/>
          </li>
          <li>
            <a href="">David Brooks: The Devotion Leap</a>
            <img src="images/brooks.png"/>
          </li>
          <li>
            <a href="">36 Hours: What to Do in Denver</a>
            <img src="images/36hours.jpg"/>
          </li>
        </ol>

  </div

CSS

#most-emailed{
  width:250px;
  height:500px;
  float:right;
  border-top:1px solid #C9C9C9;
  border-bottom: 1px solid #C9C9C9;
}

#most-emailed h2{
  font-size:10px;
  margin:0;
  padding-top:10px;
  padding-bottom:10px;
  font-family:arial;
  font-weight:700;
}
#most-emailed img{
  width:30px;
  height:30px;
}

#most-emailed ol{
  padding:0;
  margin:0;

}

#most-emailed a {
  color:#6288a5;
  font-size:12px;
  vertical-align:middle;
}
#most-emailed li{
  width:100%;
  height:50px;
  text-align:left;
  list-style-type:inside;
}

Answer №1

Consider utilizing the CSS properties display: table, display: table-row, and display: table-cell in this manner:

Take a look at the JSFiddle demo here

#most-emailed{
  width:250px;
  float:left;
  border-top:1px solid #C9C9C9;
  border-bottom: 1px solid #C9C9C9;
}

#most-emailed h2{
  font-size:10px;
  margin:0;
  padding-top:10px;
  padding-bottom:10px;
  font-family:arial;
  font-weight:700;
}
#most-emailed img{
  width:30px;
  height:30px;
}

#most-emailed ol{
  padding:0;
  margin:0;
    display: table;
}

#most-emailed a {
  color:#6288a5;
  font-size:12px;
}

#most-emailed li img {
    height: 50px;
    width: 50px;
}
#most-emailed li{
  width:100%;
    height: 50px;
    display: table-row;
}
#most-emailed li a,
#most-emailed li img {
    display: table-cell;
    height: 50px;
    vertical-align: middle;
    padding: 5px;
}


Enjoy the benefits of using tables in your layout without the complications associated with traditional tables. Embrace the simplicity of modern web design.

Edit:
To maintain the table-cell CSS formatting, consider adding numbers as spans within the list items:

 <li>
     <span>1</span>
     <a href="">Well: Writing Your Way To Happiness</a>
     <img src="images/well.jpg"/>
 </li>

#most-emailed li span,
#most-emailed li a,
#most-emailed li img {
    display: table-cell;
    height: 50px;
    vertical-align: middle;
    padding: 5px;
}

Check out the updated demo on JSFiddle

Answer №2

If you're looking for a solution, consider utilizing a table element.

<ul>
   <li><table><tr><td><a href="mylink.com">My Link</a></td><td><img src="#" /></td></tr></table></li>
   <li>[[repeat process]]</li>
    ...
</ul>

Answer №3

Make sure to align your images to the left

#most-emailed li{
float:left; <!-- this code will move text to the left of the image -->
width:80%; <!-- allocate some space for the image -->
height:50px;
text-align:left;
list-style-type:inside;
}

#most-emailed img{
float:left; <!-- this will position the image to the right of the text -->
width:20%; <!-- width set as a percentage -->
height:30px; <!-- you may consider removing this line -->
}

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

The collapsible tree nodes overlap one another in the D3.js visualization

I'm currently working on integrating a d3 code into Power BI for creating a collapsible tree structure. Each node in the tree is represented by a rectangular box, but I've run into an issue where nodes overlap when their size is large. Below is t ...

Learn how to easily incorporate a drop-down list into the material-UI Search component within the navbar to enhance the search results

I integrated a Material UI search bar into my React app's navbar following the instructions from the official documentation on MUI. However, the article does not provide any guidance on how to add a dropdown list when selecting the search input field. ...

What is the reason for the absence of a shorthand property in CSS that combines width and height measurements?

Have you ever thought about using a shorter property for specifying an item's width and height in CSS? Currently, we have to write: selector {width: 100px; height: 250px;} While this is already pretty fast, wouldn't it be even quicker if we c ...

How to Customize Bootstrap Colors Globally in Angular 4 Using Code

I am interested in developing a dynamic coloring system using Angular. I have set up a service with four predefined strings: success, info, warning, and danger, each assigned default color codes. My goal is to inject this service at the root of my applicat ...

Blazor: Passing a CSS class as a parameter to a child component

Is there a way to ensure css isolation works properly when passing a class as an argument to a child component? In the following code snippet, I anticipated the child component would display in blue, but that's not happening. Parent.razor <div cla ...

CSS: Position an element based on the size of the screen

I'm currently developing a program that will dynamically resize elements based on the viewer's screen size. The program is being built using JSP/SQL/XHTML/CSS, and I have a couple of queries. Is there a way to select a CSS file by storing the sc ...

JS | How can we make an element with style=visibility:hidden become visible?

HTML: <div id="msg-text"><p><b id="msg" name="msg" style="visibility:hidden; color:#3399ff;">This is a hidden message</b></p></div> JS: $('#url').on('change keyup paste', function() { $('# ...

Surprising behavior of translateZ in Framer Motion

Trying to position elements in a circular layout has led to unexpected behavior when using framer motion's translateZ. By applying styles with a template literal without shorthand for transforms, the desired effect is achieved: transform: ` rotateY( ...

Increase the size of the image while ensuring the content on the right remains proportionate

I have a challenge with managing two different sizes of images (vertical and horizontal) that need to remain the same size. I am attempting to create a container that can hold the image without affecting the surrounding content, while also possibly using o ...

How to use AngularJS to collapse various panels with unique content

Hey everyone, I'm working on developing a collapsible panel using Angular. The panel should consist of a header and body to display the content. The desired behavior is that when a button is clicked, the content collapses down, and clicking the same b ...

Highcharts 3D Pie Chart with Drilldown Feature

How can I create a 3D Pie Chart with Drilldown effect? I am having trouble understanding how it works. Here is a JsFiddle Demo for a 3D Pie Chart: JsFiddle Demo And here is a JsFiddle Demo for a 2D Pie Chart with Drilldown feature: JsFiddle Demo You can ...

Why is it that when the form is submitted, the value becomes unclear?

This is a form with HTML and TypeScript code that I am working on. <form> <div class="form-group"> <input class="form-control" ([ngModel])="login" placeholder="Login" required> </div> <div class="form-group"> &l ...

Guide to changing the class of a particular child element when the parent element is clicked with vanilla JavaScript

Upon clicking the parent button, a class within its child element will toggle to show or hide. If the child element is selected, a loading animation will appear for a brief moment before reverting back to its original hidden state. I attempted to achieve ...

Incorporating a hyperlink within a list item for an image

Currently, I am attempting to create a clickable image within an unordered list. Although the paragraph is clickable, unfortunately, the image itself is not responding as expected. <ul> <a href="/movies/test/"><li> ...

Can we resize the button to match the width of the blue bar?

.nav-info { height: auto; background-color: darkblue; color: white; padding: 1em; padding-left: 5%; flex-direction: row; justify-content: space-between; } .flexbox { display: flex; } .info a { color: white; text-decoration: none; fo ...

Is there a way to align the image block-grid from left to right?

Is there a way to change the alignment of images in the x-block-grid four-up class to be RTL on this page? () I have managed to make the h2 tag RTL using the following code: <h2 class="h-custom-headline h5 accent" dir="rtl"><span>Code</spa ...

Issues with CSS rendering in the Chrome browser are causing display problems

After successfully creating an iFrames page tab on Facebook that looks great in Firefox and Internet Explorer, I encountered an issue with the div positioning in Chrome. You can view the page here: Oddly enough, this is the only page experiencing problems ...

Using an external JavaScript script may encounter difficulties when loading pages with jQuery

Trying to utilize jQuery for loading html posts into the main html page and enabling external scripts to function on them. Utilizing a script (load.js) to load posts into the index.html page: $(document).ready(function () { $('#header').loa ...

Verifying the status of a checkbox label in Java using Selenium

I am currently working on an automation project using Selenium and I'm struggling to figure out how to check the status of a checkbox input. Has anyone else encountered this issue before? Here is a sample code snippet in JavaScript with jQuery: $("i ...

SDTT is showing an error that says "The review has no specified reviewed item," even though I have properly utilized the 'itemReviewed' property

I have attempted using itemReviewed in various tags, but it doesn't seem to be working as I keep getting the following error: The review has no reviewed item specified. Click here for a scan on Google's Structured Data Testing Tool. <!-- ...