Attempting to evenly distribute images using CSS styling

I am attempting to design a slideshow with small images evenly distributed horizontally on each slide. I came across an intriguing technique on css-tricks.com and a very straightforward working example, but I have not been successful in replicating it.

Below is the HTML code for a slide:

<div class="item active">
  <div>
    <a href="#"><img src="http://placehold.it/100x100"></a>
    <a href="#"><img src="http://placehold.it/100x100"></a>
    <a href="#"><img src="http://placehold.it/100x100"></a>
    <a href="#"><img src="http://placehold.it/100x100"></a>
    <a href="#"><img src="http://placehold.it/100x100"></a>
    <a href="#"><img src="http://placehold.it/100x100"></a>
    <a href="#"><img src="http://placehold.it/100x100"></a>
  </div>
</div>

Here is the CSS following the mentioned technique:

div.sites .carousel-inner .item div {
  font-size: 0.1px;
  text-align: justify;
}

div.sites .carousel-inner .item div:after {
  content: "";
  width: 100%;
  display: inline-block;
}

div.sites .carousel-inner .item div a {
  display: inline-block;
}

You can view the functioning code at the bottom of this site, under the title "OTROS SITIOS"

EDIT: My girlfriend tested out my code in CodePen and it worked smoothly. I suspect there may be some global style interfering with it.

Thank you for your assistance

Answer №1

After copying the html layout from the div elements, I pasted it onto CodePen with your suggested css styling. I noticed that there was a missing escape character between the </a> and <a> tags.

Once I included it, the code functioned flawlessly :)

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

Hover effects in CSS using z-index are causing the displacement of divs

Whenever I hover over the first div to reveal the entire text, the second div's position shifts to go behind it. My goal is to have the second div stay in place, allowing the text from the first div to overlap it. Check out the demo here: https://cod ...

Maintaining proportionality using CSS (if achievable)

Having a small issue with image heights here. To see the problem in action, check out this demo. In the demo, you'll notice that the "rocket raccoon" image is taller than the others. .gallery-elements .gallery-image-big { position: relative; } ...

Is it possible to center an anchor link in React JS using Webpack, Sass, and Bootstrap 4?

Recently, I started delving into React JS and Webpack but encountered a perplexing issue. My goal is simple - to center an anchor link on the screen. However, despite trying various methods like inspecting the element, removing inherited styles, setting wi ...

Is there a way to enable horizontal scrolling for a div table within an iframe element?

Looking for a solution to scroll a table horizontally to specific locations by clicking anchor tags outside of its frame? I initially used inline js which worked with the old table, but after updating to CSS, it stopped working. Seeking assistance from exp ...

Expanding the height of Bootstrap 4 cards

I'm having an issue with Bootstrap 4's card columns where the height of the shorter card ends up stretching to match the one beside it. This only occurs when I add the 'row' class to the parent div. If I remove the 'row' class ...

What other option can be used in place of white-space:nowrap?

When using a textarea with the CSS property white-space:nowrap, it successfully removes spaces but adds a horizontal scrollbar to the text. I want to avoid the horizontal scrollbar while also preventing scrolling using arrow keys when using overflow-x:hi ...

Allowing Users to Easily Copy CSS ::before Content

Text inserted via pseudo-elements like ::before and ::after cannot be selected or copied. Is there a way to change this behavior? span::before { content: "including this text"; } <p> When the text of this paragraph is selected and copied, ...

event fails to trigger on a fixed positioned element

Here's the code snippet I've been working with: if ($('body.page-service-map').length || $('body.page-contact').length) { $(document.body).append('<div class="black-overlay"></div>'); ...

Height of inline-block list items in ul is not properly adjusted

I am working on a horizontal navigation bar using inline-block for the li tags. Here is the code snippet: <ul> <li><a href="#">HOME</a></li> <li><a href="#">FEATURES</a></li> <li><a href ...

Material UI AppBar fixed position that is not part of a grid container

Hey everyone, I'm really struggling with this issue. I recently set my AppBar to have a position of "fixed". However, now the appbar is no longer contained within its container and instead spans the entire screen. I've been trying to figure it ou ...

Header bar/navigation bar that is constantly changing

Hi there, I'm in the process of creating a dynamic header/navigation bar similar to the one on this website: Here's what I have so far: Jquery: $(document).ready(function() { var lock = $('#header').position().top; $(window).scroll(f ...

Prevent child div from resizing along with parent div during a resize event by utilizing the .resizable()

Check out this example here I am able to resize the div using jQuery, but I don't want the #spacer to have a fixed width at first because the content of the could vary in size. Even if I remove: width:100px; and try setting it to a percentage or ...

Transition effects in the gallery are only triggered once all images have been seen

*Update 2 After identifying that the images were not fading in/out due to being considered unloaded, I resolved the issue by incorporating the initial 3 lines of jQuery code. I anticipate refactoring this and will provide an update once completed. JSFidd ...

Discover the beauty and color of transforming markdown to HTML using Python

Is there a way to convert markdown text into beautiful, colorful HTML using Python? I've tried searching online, but all I can find are results related to the Markdown library. The code snippet provided only generates plain HTML with no color or styli ...

Extract CSS from Chrome developer tools and convert it into a JavaScript object

Recently, we have started incorporating styles into our React components using the makeStyles hook from Material-UI. Instead of traditional CSS, we are now using JavaScript objects to define styles. An example of this is shown below: const useStyles = ma ...

Custom TailwindCSS Theme Builder

My goal is to implement a variation of themes and be able to switch between them using tailwind CSS. I came across a tutorial on YouTube regarding this topic in JavaScript youtube video, but I am working with TypeScript and encountering issues with a cus ...

Scrolling sensation: Gradually starts off leisurely before picking up speed

Trying to implement a unique scrolling effect where, upon triggering the onclick event, I want the div1 element to smoothly scroll towards dev2. The movement should start slow and then increase in speed! Check out an example of this effect on a website: ...

Is there a way to achieve the desired outcome without relying on Bootstrap?

I stumbled upon a code snippet in an online article which showcased a live demo accessible through this link Upon further investigation, I managed to craft a simple modal using just a few lines of jquery and CSS without relying on bootstrap. For instance ...

"Is it possible to keep an eye on two different events and take action once they both

I have a menu with different submenus for each list item, all utilizing the same background tag. Currently, when one submenu is open and I hover over another list item, the previous submenus hide and the new one opens. What I want is for the content to cha ...

What causes the div to shift while performing the FadeIn-FadeOut effect?

It seems like there might be something that I'm overlooking, as I am encountering a minor issue with this. I am aiming to align the "submenu div" on the right side of the Show/hide links. Initially, when I load the div, it is correctly positioned. H ...