The CSS listings in the unordered list using the inline-block property are misaligned

My unordered list (ul) and list items (li) have a display set to inline-block.
Each li contains an image and a div positioned below the image.
The lis do not align in the same row when the divs vary in height.

Here is a sample image for reference:

Note: The images used here are just for testing purposes :)

Below is the CSS code:

.uldaftarartikel ul{<br/>
    list-style-type: none;margin: 0 auto;padding: 0;text-align:center;<br/>
}<br/>
.uldaftarartikel ul li{<br/>
    display: inline-block; margin:7px;width: 170px;height: 272px;<br/>
}<br/>
@media (min-width: 700px) and (max-width: 1299px){<br/>
    .uldaftarartikel ul li{width: 200px;}<br/>
}<br/>
@media (min-width: 1300px){<br/>
    .uldaftarartikel ul li{width: 227px;}<br/>
}<br/>
.uldaftarartikel ul li a{<br/>
    display: block;text-decoration: none;height: 272px;<br/>
}<br/>
.uldaftarartikel ul li a:hover{<br/>
    text-decoration: none;<br/>
}<br/>

.uldaftarartikel ul li a .gambarartikelchange{<br/>
    background-color: transparent;<br/>
}<br/>
.uldaftarartikel ul li a .gambarartikelchange:hover{<br/>
    background: rgb(255,241,103);<br/>
}<br/>
.uldaftarartikel ul li a .gambarartikelchange img{<br/>
    width: 100%;height: auto;opacity:1;transition:opacity 1.5s;height: 112px;<br/>-webkit-backface-visibility: hidden;-ms-transform: translateZ(0); /* IE 9 */
    -webkit-transform: translateZ(0); /* Chrome, Safari, Opera */transform: translateZ(0);<br/>
}<br/>
.uldaftarartikel ul li a .gambarartikelchange img:hover{<br/>
    opacity: 0.4;<br/>
}<br/>
.uldaftarartikel ul li a .keterangandaftarartikel{<br/>
    color: rgb(127,71,51);transition:color 1.5s;height: 150px;padding:5px;<br/>
}<br/>
.uldaftarartikel ul li a .keterangandaftarartikel:hover{<br/>
    color:rgb(204,88,47);<br/>
}<br/>



Here is the HTML code snippet:

<div class="uldaftarartikel"><br/>
<ul><br/>
  <li><a href="#"><div class="gambarartikelchange"><img src="gambarartikel/1.jpg" ></div><div class="keterangandaftarartikel">fqwgegg<br/>asfagdg</div></a></li><br/>
  <li><a href="#"><div class="gambarartikelchange"><img src="gambarartikel/2.jpg" ></div><div class="keterangandaftarartikel">3yrehdfh</div></a></li><br/>
  <li><a href="#"><div class="gambarartikelchange"><img src="gambarartikel/3.jpg" ></div><div class="keterangandaftarartikel">hshfdh5fdhj</div></a></li><br/>
  <li><a href="#"><div class="gambarartikelchange"><img src="gambarartikel/4.jpg" ></div><div class="keterangandaftarartikel">4yhuredhdt</div></a></li><br/>
  <li><a href="#"><div class="gambarartikelchange"><img src="gambarartikel/1.jpg" ></div><div class="keterangandaftarartikel">fqwgegg</div></a></li><br/>
  ... Repeat pattern of list items with different content ... 
</ul><br/>
</div><br/>

Although it may seem simple, I encountered some challenges and felt a bit overwhelmed. Thank you for your help!

Answer №1

For optimal display, apply the following CSS rule: .uldaftarartikel ul li{float:left}

Answer №2

These are the accurate responses:
1. .uldaftarartikel ul li{float:left} Thank you, HirenPatel.
2. .uldaftarartikel ul li{vertical-align:top} Thank you, MrLister.

Why am I unable to mark their response as the solution? Apologies, I am new to this forum :)
And a beginner in CSS hahahaha

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 navigation buttons and slide indicators on the Bootstrap 5 carousel are failing to function properly

I am encountering an issue with my simple bootstrap carousel on my HTML page. The controls do not seem to be functioning properly and the indicators are not appearing. edit: After reviewing the documentation, I followed the instructions provided but the p ...

The outer container does not have a specified height

I have a main #slider div containing multiple images. Each image is set to position: absolute; for automatic resizing within the slider. The issue arises when setting images this way, causing the height of the #slide div to become zero and preventing cont ...

The <label> tag is divided into several lines

I'm facing an issue with the <label> element in my ASP.NET Core MVC project. Instead of displaying in a single line, it's splitting into multiple lines. Upon inspecting the element in Google Chrome, I noticed that it's inheriting style ...

Utilize the Sed command to manipulate the input stream by substituting all occurrences of HTML <i> tags with <em> tags

I am attempting to create a regex with the sed command in order to process the input stream and replace all HTML tags with em tags. For example: This is <i id="x">emphasized text</i> and <i>so is this</i>. should be replaced by Thi ...

Create a Sleek Dropdown Navigation Menu with MaterializeCSS in WordPress

I am having trouble displaying the dropdown menu on my WordPress website. How can I make sure the dropdown menu appears properly? functions.php register_nav_menus( array( 'primary' => __( 'Primary Menu', 'TNCTR-OnePage' ) ...

What's the reason behind CSS transitions starting with a black background?

When I apply a transition to the heart, it inexplicably turns black at the start of the animation before displaying the intended gradient effect. Below is the code snippet: .heart { font-size: 2.5rem; padding-right: 2rem; } .heart:hover ...

The getElementBy method is failing to pass the value in the document

Here is the javascript code snippet I am using: document.getElementById('district').value = dist.long_name "this line is passing the value" document.getElementById('city').value = route.long_name "this doesn&apos ...

Having difficulty populating a select input with data from the state

declaring an empty object as the initial state const [categories, setCategories] = useState({}); fetching data from an API using axios and updating the state with the response const res = await axios.get(`${API}/categories`); setCategories(res.data ...

Slide a floating container downward by one line

I am in search of a way to create a unique text effect resembling a "sidebox" within my writing. The goal is to have a note or heading positioned at the start of a paragraph, floating either to the left or right with some negative space surrounding it and ...

Expanding SVG width upon import through Icomoon

After exporting an SVG file from Illustrator (already "Fit to selected Art"), I encountered an error while importing it via the Icomoon App. Strangely, other SVGs are importing correctly. I would appreciate any help or insight you can provide. Thank you i ...

Arranging Data in an HTML Table Using TableSorter

I have been trying to incorporate sortable columns into my HTML table and decided to experiment with the jquery tablesorter. I have followed the syntax below, but for some reason, my table is not allowing me to sort. Can you help me understand why? &l ...

Enhance your navbar with interactive image effects on hover

Looking to create a CSS menu that changes images and background when hovered over. Below is the code for my menu: HTML <ul> <li class="active1"> <a href="profile.html" class="act">My Profile</a></li> <li><a ...

Ways to create space between rows

Here is some code structure that I'm working with: .col_1_6 { width: 70%; float: left; } .col_1_4 { width: 30%; float: left; } .row-content { clear:both; padding-bottom: 105px; } <div class="row-content"> <div ...

What is the most effective way to use Javascript to update an image depending on the selected value in a dropdown

My JavaScript skills are limited, but I have successfully created a form with 4 drop-down selection boxes on the left side for users to choose from (State, Car, Year, Condition). After making their selections, users can click a 'calculate' butto ...

When using JavaScript, I have noticed that my incremental pattern is 1, 3, 6, and 10

I am currently using a file upload script known as Simple Photo Manager. Whenever I upload multiple images and wish to delete some of them, I find myself in need of creating a variable called numDeleted (which basically represents the number of images dele ...

Upon clicking a button on page 1, the data is transmitted to page 2 before redirecting the user to page 3

When a user enters information into a text field on page1.php and clicks the submit button, the data is sent to page2.php where it is used to query a database and save it in an XML file. <Form name="search_form" method="POST" action="page2.php"> ...

resizing problem with images that adapt to different screen sizes

I've been working on creating a responsive website, but I'm having trouble with the resizing of the two background images I added to the header. When I view the site on a mobile device, the header appears squashed. I think this might be because I ...

The Three JS on the website is error-free, yet it fails to function properly

I've been attempting to replicate the example three.js page on my own website, complete with a canvas for the 3D animation. However, I'm encountering an issue where nothing is displayed, despite no errors appearing. I've tried troubleshootin ...

What could be causing the issue with the width: 100% not rendering correctly in this

I'm currently working on my footer, but I'm having trouble getting the width: 100% tag to work correctly. Here's a screenshot of what I mean: http://gyazo.com/9c23897cd7b9a74ca55ee9fb977f810c This is my CSS code: /*..Portfolio - Lars Beut ...

Get the identification number from a div located within an array of JSON objects using only JavaScript

I've scoured the internet for solutions to my problem, but nothing seems to work as I need it to. I've attempted various methods, including using href and button with the router, but unfortunately, none of them fit the specific requirements in th ...