Displaying items side by side instead of stacking them on top of each other can be achieved by utilizing the <ul><li>

My webpage displays items vertically, but I need them to be horizontal. Which CSS element should I use to achieve this?

This is the code snippet:

<ul class="jobs">
        <li>
            <img height="80px" src="http://pbs.twimg.com/media/CEQnmWnWgAArgtf.jpg" />

                <div class="company">desc1</div></li>

        <li>
            <img height="80px" src="http://pbs.twimg.com/media/CEQnmWnWgAArgtf.jpg" />

                <div class="company">desc2</div></li>
    </ul>

Check out the demo page here:

Answer №1

.employment {
list-style-type: none;
padding:0;
margin:0;
}

.jobs > li {
display: inline-block;
}

Does this resemble what you were thinking?

Answer №2

To get your list items to align horizontally, set the display property to inline.

Here's an illustration:

li{display:inline}
<ul>
   <li>1</li>
   <li>2</li>
   <li>3</li>
</ul>

Answer №3

employ

ul {
    display: inline-block;
}

for spacing the unordered list items next to each other.

Answer №4

To align elements side by side, you can utilize the float property in CSS. However, be sure to clear after floating elements to avoid any layout issues.

For example:

.jobs {
  list-style: none;
}

.jobs li {
  float: left;
  margin-left: 12px;
}

.jobs::after {
  content: "";
  display: table;
  clear: both;
}
<ul class="jobs">
  <li>
    <img height="80px" src="http://pbs.twimg.com/media/CEQnmWnWgAArgtf.jpg" />

    <div class="company">desc1</div>
  </li>

  <li>
    <img height="80px" src="http://pbs.twimg.com/media/CEQnmWnWgAArgtf.jpg" />

    <div class="company">desc2</div>
  </li>
</ul>

Answer №5

Avoid using floats for layout unless absolutely necessary as they can be quite buggy. Floats are best utilized for removing an element from the normal document flow while allowing content to wrap around it, such as with an image within a paragraph.

Instead of using floats, consider setting font size: 0 on the container to eliminate unwanted white space between items and use white-space: nowrap to keep them in line when the container exceeds the window size. Then reset the font and white-space properties in the child elements and set them to display: inline-block.

By opting for inline-block instead of inline, you gain the ability to adjust the width and height of each element individually.

Note: Setting the font for html to reference later enables the use of rem units that correspond to the font size of the root element. For instance, 1rem in this scenario resets the font size to match that of the root element.

ul {
    font-size: 0;
    white-space: nowrap;
}
li {
    display: inline-block;
    font-size: 1rem;
    white-space: initial;
}

Answer №6

If you're looking for a way to showcase information, consider using a table:

<table>
  <tr>
    <td>
      <img height="80px" src="http://pbs.twimg.com/media/CEQnmWnWgAArgtf.jpg" />
      <div class="company">description 1</div></li>
    </td>
    <td>
      <img height="80px" src="http://pbs.twimg.com/media/CEQnmWnWgAArgtf.jpg" />
      <div class="company">description 2</div></li>
    </td>
  </tr>
</table>

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

Trouble with implementing Angular Material button color when using routerLinkActive

For my application, I am implementing Angular Material and have configured the button as follows: <mat-toolbar> <span> <a routerLink="/">My Messages</a> </span> <ul> <li> <a mat ...

Ensure that a div with fluid width remains consistently centered within another div

I have a bunch of boxes filled with content. The number of boxes in each row varies depending on the width of the browser window. Is there a way to ensure that all the boxes are always horizontally centered on the page? For guidance, you can check out th ...

Is it possible to increase the delay in the nth-child selector?

I'm attempting to create a compact checklist that displays in a single row with items appearing sequentially. To achieve this, I utilized the :nth-child() selector in CSS as shown below: .animated { -webkit-animation-duration: 0.8s; animation-d ...

Adjust the Weight of a Single Word in H1 CSS

I've been trying to figure out how to achieve the following for a while now. I know I can solve this issue by using different h1 tags and positioning them separately, but I'm curious to find out if there's a way to do it without dividing the ...

Is CodeMirror's PHP mode failing to function properly?

There seems to be an issue with displaying the highlighted text, and I'm not sure why. Links: <link rel=stylesheet href="http://codemirror.net/mode/php/../../doc/docs.css"> <link rel="stylesheet" href="http://codemirror.net/mode/php/../../l ...

What is the best way to expand this HTML5 canvas script to fill the entire screen?

I am having issues adjusting the canvas to fill the entire window. Currently, it is set to 500x500. As a beginner in coding, any assistance would be greatly appreciated! Thank you. Below is the code snippet: <!DOCTYPE html> <html> <head& ...

Designing a dropdown menu using CSS

Currently, I am facing a requirement to create a menu that should resemble the image provided below. In the past, I have experience working on simple drop-down menus, but this time the specifications are a bit unique. The top menu links should change colo ...

What methods can be used to identify the specific Router component being rendered in React?

I am currently working with a Navbar component that I want to render with different CSS styles using styled-components based on the route of the component being rendered. How can I determine whether that component is being rendered or not? const NavbarCont ...

What is the best way to align a container in the middle of the page without positioning the text in the center

Query 1: What is the best way to horizontally center the container div while keeping Typography aligned to the left? Expected outcome: https://i.stack.imgur.com/yKCZF.jpg Query 2: How can a component be positioned below the AppBar without relying on mar ...

Tips for structuring a webpage section on a smaller screen using Bootstrap

Good day, I am inquiring about how to adjust the formatting of a website element when viewed on a different browser size. For instance, this is what my top navigation bar looks like at the LG size: Nav LG However, when I switch to SM size, it appears u ...

What is the best way to apply the same effect to multiple images without affecting the ones I haven't hovered over?

I am currently facing an issue with 6 images displayed in a table, 3 per row across 2 rows. I applied the "grow" effect to all the images but it seems like everything is moving around in a confusing manner. Does anyone have suggestions on how I can resolve ...

Using ion-icon inside a clickable ion-card while applying float: right does not render properly

I am facing an issue with a list of ion-cards that have clickable icons appearing when you hover over them. The problem is that due to the floating nature of the icons, they are not positioned correctly (as shown in the image below) and end up getting cove ...

The CSS file is failing to recognize the changes made to the data-theme attribute in the HTML

Currently implementing a dark theme on my website involves adding a toggle switch to the footer.html page, which adds a variable named data-theme = 'dark' to the html. The scss files of the footer and core are adjusting accordingly based on the c ...

sophisticated HTML navigation bar

I am looking for a way to create a menu where the drop-down items overlay the rest of the menu when the screen width is small. Here is my current code: nav{ line-height:100%; opacity:.9; }nav ul{ background: #999; padding: 0px; border-radius: 20px; ...

What steps are involved in building a modal pop-up in Angular without using any pre-existing libraries

I am looking to create a modal popup when a button is clicked. I want to achieve this without relying on any additional dependencies. The method I have used below successfully creates a fully functional modal, but I am unsure if this is the best way to do ...

Position the table at the bottom of the page using CSS

I'm experiencing an issue where my HTML is not rendering correctly. I need to move the table with the ID "footer" to the bottom of the page. Here's the structure of the situation: <div id="container"> <table id="footer"></tabl ...

Tips on adjusting section height as window size changes?

Working on a website that is structured into sections. Initially, all links are aligned perfectly upon load. However, resizing the window causes misalignment issues. Check out my progress at: karenrubkiewicz.com/karenportfolio1 Appreciate any help! CSS: ...

How to set a DIV width in CSS to enable scrolling on an iPad 2

Greetings, I have a simple CSS query that I would like assistance with. I am currently grappling with the concept of managing widths in CSS. I have an absolute positioned <div> that contains a relatively wide table. The width of the <div> is s ...

`Exploring the magic of CSS image overlay feature`

I would appreciate it if you could walk me through the implementation of this overlay code... .overlay { position: absolute; top: 0; bottom: 0; left: 0; right: 0; height: 100%; width: 100%; opacity: 0; transition: .5s ...

What causes the unusual behavior of `overflow-x: auto;` when used within a parent element with `flex-direction: row;` styling

I have gone through numerous other queries regarding horizontally scrolling tables, but none seem to address this particular problem. When using a responsive table in the default Blazor Server template of a new project built with Bootstrap 4, the browser ...