Centered horizontally are images that have been floated

How can I align images with different widths when they are all floated right? I want them to be aligned vertically below each other.

For the best display, please view in fullscreen on your computer as the example window is small.

.compressor{
height: 150px;
float: right;
}
<div>

<a href="../photos/ESM250.gif" rel=lightbox[compressor1] data-title="Gardner Denver ESM250 compressor"><img src="http://matmasar.wz.cz/fotky/ESM250.gif" title="Gardner Denver ESM250 compressor" alt="Gardner Denver ESM250 compressor" class="compressor"></a>
-Screw compressors system load - unload, type <b>ESM 2-500</b>
<ul>
<li>Constant motor speed</li>
<li>Delivery volume: 0.24 - 73.60 m<sup>3</sup> /min</li>
<li>Output pressure: 5 - 13 bar</li>
<li>Power up to 500kW</li>
</ul>
</div>


<div>
-Screw compressors with frequency converter, type <b>VS7 - VS290</b>
<a href="../photos/GD_VS7.gif" rel=lightbox[compressor2] data-title="Gardner Denver VS7 compressor"><img src="http://matmasar.wz.cz/photos/GD_VS7.gif" title="Gardner Denver VS7 compressor" alt="Gardner Denver VS7 compressor" class="compressor"></a>
<ul>
<li>Variable motor speed = higher operational efficiency</li>
<li>Delivery volume: 0.41 - 42.30 m<sup>3</sup> /min</li>
<li>Output pressure: 5 - 13 bar</li>
<li>Power up to 290kW</li>
</ul>
</div>


<div>
-Oil-free screw compressors series <b>Ultima U75 - 160 PureAir</b>
<a href="../photos/UltimaU75-160_PureAir.gif" rel=lightbox[compressor3] data-title="Gardner Denver Ultima U75-U160 compressor"><img src="http://matmasar.wz.cz/photos/UltimaU75-160_PureAir.gif" title="Gardner Denver Ultima U75-U160 compressor" alt="Gardner Denver Ultima U75-U160 compressor" class="compressor"></a>
<ul>
<li>Unique design - high efficiency, low noise</li>
<li>Variable motor speed</li>
<li>100% oil-free air, ISO 8573-1 Class Zero (2010) compliant</li>
<li>Power up to 160kW</li>
</ul>
</div>

Answer №1

When utilizing the float property, the floating element does not affect the height of its parent element. The following <div> cannot utilize the full width because it is not completely positioned below the floated image from the previous <div>. In order to ensure that it starts fully below all float elements, you must apply clear: both;. I have made adjustments to your example code to illustrate this:

.kompresor{
height: 150px;
float: right;
}
.clear-both {
  clear: both;
} 
<div>

<a href="../fotky/ESM250.gif" rel=lightbox[kompresor1] data-title="kompresor Gardner Denver ESM250"><img src="http://matmasar.wz.cz/fotky/ESM250.gif" title="kompresor Gardner Denver ESM250" alt="kompresor Gardner Denver ESM250" class="kompresor"></a>
-Mazné šroubové kompresory systém zatíženo – odlehčeno, typ <b>ESM 2 -500</b>
<ul>
<li>Stálá rychlost motoru</li>
<li>Dodávaný objem: 0,24 – 73,60 m<sup>3</sup> /min</li>
<li>Výstupní tlak: 5 - 13 bar</li>
<li>Výkon až 500kW</li>
</ul>
</div>


<div class="clear-both">
-Mazné šroubové kompresory s frekvenčním měničem, typ <b>VS7 – VS290</b>
<a href="../fotky/GD_VS7.gif" rel=lightbox[kompresor2] data-title="kompresor Gardner Denver VS7"><img src="http://matmasar.wz.cz/fotky/GD_VS7.gif" title="kompresor Gardner Denver VS7" alt="kompresor Gardner Denver VS7" class="kompresor"></a>
<ul>
<li>Proměná rychlost motoru = vyšší efektivita provozu</li>
<li>Dodávaný objem: 0,41 – 42,30 m<sup>3</sup> /min</li>
<li>Výstupní tlak: 5 - 13 bar</li>
<li>Výkon až 290kW</li>
</ul>
</div>


<div class="clear-both">
-Bezmazné šroubové kompresory řady <b>Ultima U75 – 160 PureAir</b>
<a href="../fotky/Ultima U75-160_PureAir.gif" rel=lightbox[kompresor3] data-title="kompresor Gardner Denver Ultima U75-U160"><img src="http://matmasar.wz.cz/fotky/Ultima U75-160_PureAir.gif" title="kompresor Gardner Denver Ultima U75-U160" alt="kompresor Gardner Denver Ultima U75-U160" class="kompresor"></a>
<ul>
<li>Jedinečný design – vysoká efektivita, nízký hluk</li>
<li>Proměná rychlost motoru</li>
<li>100% čistý vzduch bez oleje, splňuje ISO 8573-1 Class Zero (2010)</li>
<li>Výkon až 160kW</li>
</ul>
</div>

Answer №2

To achieve a centered column layout with images on the right side of text, you can implement the following HTML markup and CSS styling.

(1) Start by adding a wrapper div.table-wrap element with a property of display: table.

(2) Set display: table-row for the child div elements inside the wrapper.

(3) Place the top line of text (title) as the first item (li) in a ul block, give it the class title, and style it accordingly. Position the a element after the ul block.

(4) Apply display: table-cell to both the ul and a elements, using vertical-align: top and text-align: center for the a element.

(5) Fine-tune the margins and padding to optimize white space distribution.

The wrapper styled with display: table facilitates centering the images in a CSS-table column. You can also choose to center the entire table if needed.

This layout offers decent responsiveness and allows control over spacing through margin and padding adjustments.

div.table-wrap {
  display: table;
  width: auto;
  margin: 0 auto; /* Optional: center the table/panels */
}

div.table-wrap div {
  display: table-row;
}

div.table-wrap ul {
  display: table-cell;
  vertical-align: top;
  margin: 0;
  padding: 0;
}

div.table-wrap ul li {
  margin-left: 20px;
}

div.table-wrap ul li.title {
  list-style: none;
  font-size: 1.00em;
  margin: 0 0 10px 0;
}

div.table-wrap a {
  display: table-cell;
  vertical-align: top;
  text-align: center;
}

div.table-wrap a img {
  height: 175px;
  padding-left: 20px;
}

div.table-wrap ul,
div.table-wrap a {
  padding-bottom: 10px; /* Affects row/panel spacing */
}
<div class="table-wrap">
  <div>
    <ul>
      <li class="title">- Lubricated screw compressors, load-unload system, type <b>ESM 2 -500</b></li>
      <li>Constant motor speed</li>
      <li>Discharge volume: 0.24 – 73.60 m<sup>3</sup>/min</li>
      <li>Output pressure: 5 - 13 bar</li>
      <li>Power up to 500kW</li>
    </ul>
    <a href="../photos/ESM250.gif" rel=lightbox[compressor1] data-title="Gardner Denver ESM250 compressor"><img src="http://example.com/photos/ESM250.gif" title="Gardner Denver ESM250 compressor" alt="Gardner Denver ESM250 compressor" class="compressor"></a>
  </div>
  <div>
    <ul>
      <li class="title">- Lubricated screw compressors with frequency converter, type <b>VS7 – VS290</b></li>
      <li>Variable motor speed = increased operational efficiency</li>
      <li>Discharge volume: 0.41 – 42.30 m<sup>3</sup>/min</li>
      <li>Output pressure: 5 - 13 bar</li>
      <li>Power up to 290kW</li>
    </ul>
    <a href="../photos/GD_VS7.gif" rel=lightbox[compressor2] data-title="Gardner Denver VS7 compressor"><img src="http://example.com/photos/GD_VS7.gif" title="Gardner Denver VS7 compressor" alt="Gardner Denver VS7 compressor" class="compressor"></a>
  </div>
  <div>
    <ul>
      <li class="title">- Oil-free screw compressors series <b>Ultima U75 – 160 PureAir</b></li>
      <li>Unique design – high efficiency, low noise</li>
      <li>Variable motor speed</li>
      <li>100% oil-free air, compliant with ISO 8573-1 Class Zero (2010)</li>
      <li>Power up to 160kW</li>
    </ul>
    <a href="../photos/Ultima_U75160_PureAir.gif" rel=lightbox[compressor3] data-title="Gardner Denver Ultima U75-U160 compressor"><img src="http://example.com/photos/Ultima_U75160_PureAir.gif" title="Gardner Denver Ultima U75-U160 compressor" alt="Gardner Denver Ultima U75-U160 compressor" class="compressor"></a>
  </div>
</div>

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

What is the best way to scale down my entire webpage to 65%?

Everything looks great on my 1920x1080 monitor, but when I switch to a 1024x768 monitor, the content on my webpage becomes too large. I've been manually resizing with CTRL+Scroll to reduce it to 65%, which works fine. Is there a code solution using CS ...

When attempting to add a new row to a table, the function fails to function properly

I am facing an issue with my dynamic HTML table. Each row in the table should have two cells whose values are multiplied together. I have created a function to achieve this, but it only works on the first row of the table and not on any new rows added by c ...

Collapse dropdown menus upon clicking outside of them

As a newcomer to coding, I'm trying to figure out how to create multiple dropdown menus where each one collapses when you click outside of it. I've been struggling with the code I wrote for weeks now - I want to have 3 dropdown menus but only one ...

Guide to creating animated sections using only CSS as you scroll the webpage

I am searching for a method to add animation effects (using @keyframes, transform...) to certain elements as the user scrolls down the page. For instance: When the offset is 0: the div will have a height of 100px. When the offset is between 0 and 100: th ...

The website's scrolling speed is painfully slow

Currently, I am working on enhancing the performance of this site at . If you scroll through the site or navigate using the Up and Down Arrow Keys, you may notice a sluggish and slow Scroll Behaviour. I am utilizing HTML5 and simple img tags with 85% wid ...

What is the best way to securely transfer data from a Node/Express server to the client using JavaScript, ensuring sanitized HTML and preventing cross-site scripting (X

What is the best method to securely pass data from an Express backend to a client-side JavaScript in order to render it in the DOM using client-side rendering, while also allowing sanitized whitelist HTML and preventing XSS attacks? For example, if the No ...

Is there a way to handle the ajax request only when necessary, instead of processing it every few seconds?

Currently, I am working on an AJAX chat system using PHP, MySQL, JavaScript, and AJAX. I have a piece of code that retrieves all chat messages within a div using AJAX, with the function running every 2 seconds. My issue lies in the fact that the div autom ...

Identifying whether a Alphabet or a Digit has been Pressed - JavaScript

I understand that it is possible to detect if a key has been pressed and identify which key was pressed using JavaScript. In order to check if a key is down or pressed, jQuery can be utilized with ease: $( "#some id" ).keydown(function() or $( "#m" ). ...

Utilizing interpolation for a CSS class defined in an external file within Angular 2

Is it feasible to send a variable to a CSS class in an external CSS file within Angular 2, such as: import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', sty ...

Trying to configure and use two joysticks at the same time using touch events

I have been grappling with this problem for the past two days. My current project involves using an HTML5/JS game engine called ImpactJS, and I came across a helpful plugin designed to create joystick touch zones for mobile devices. The basic concept is th ...

Minimize the vertical gap between menu items when they wrap onto a new line

When examining the screenshot of the website, you'll notice a considerable space between the first and second rows of menu items. I'm aiming to minimize this spacing as much as possible. The following CSS pertains to this issue: .gva-navigatio ...

Is it possible to effortlessly download videos stored in Firebase directly from my website by simply clicking on an "a" tag?

Recently, I came across a web page that contained a list of videos. There was an icon resembling an arrow next to the "a" tag. You can view this image by clicking here. My intention was to download one of these videos hosted on Firebase by clicking on ...

Passing data from the <ion-content> element to the <ion-footer> element within a single HTML file using Ionic 2

In my Ionic 2 html page, I have a setup where ion-slide elements are generated using *ngFor. I am seeking a way to transfer the data from ngFor to the footer section within the same page. <ion-content> <ion-slides> <ion-slide *n ...

Using jQuery to Toggle Visibility of Table Rows

I'm facing a challenge in creating a basic table layout where all the table rows are initially hidden when the document loads. The goal is to display specific rows when a corresponding button is clicked, but my current implementation doesn't seem ...

Particles.js fails to persist as I scroll down the HTML page

After creating a website page, I incorporated Particles.js for the background. However, when I scroll down, the particles seem to be confined to the initial corner of the screen and do not continue downward. Here are my current particle settings: #particl ...

Enhancing Transparency of WMS Layers in OpenLayers

I need help figuring out how to add transparency to a WMS layer in openlayers. Here is the current javascript code for a non-transparent layer: var lyr_GDPSETAAirtemperatureC = new ol.layer.Tile({ source: new ol.source.TileWMS(({ ...

Guide on altering the cursor icon during an AJAX operation within a JQuery dialog

When I have a JQuery dialog open and make some $.ajax calls, why can't I change the cursor? I want to display a progress cursor while the code is processing so that users can see that the action is still ongoing. However, even though I update the CSS ...

The art of replacing material-ui styles with styled components

As a newcomer to UI material design, I am eager to create my own customized Button Component using styled-components. I am facing a challenge in overriding the CSS based on different button variations such as "primary" or "secondary". You can find my cod ...

Using JavaScript to implement CSS3 with multiple background images

Is there a way to programmatically define multiple background images in CSS3 using JavaScript? While the common approach would be: var element = document.createElement( 'div' ); element.style.backgroundImage = "url('a.png') 0 100%, ur ...

Change the appearance of a div based on the presence of a certain class within a child div using jQuery styling techniques

I'm trying to set a default padding of 15px for div.content, but if it contains a child div.products-list, I want the padding to be removed. I've looked into solutions using jquery, but nothing seems to work. Here's how my layout is structur ...