Spreading out pictures within a container

I have a collection of images that I want to evenly distribute within a container. While I've come across several similar questions with helpful solutions, many involve using padding or margins, resulting in empty gaps along the edges of the div.

Currently, I'm adding a margin-right to each image, which works well except for the last image, leaving an unappealing gap. While I could create a separate class for the final image without margin, I'm hoping for a more elegant solution. Are there any other approaches I can take?

#photo_bar {
    margin-bottom:15px;
    width:785px;
}

#photo_bar a {
    margin-right:7px;
}

.photo_bar_image {
    border-radius:9px;
    background-size: 125px;
    display: inline-block;
    width: 125px;
    height: 125px;
    text-decoration: none;
    transition: background-size 0.2s, background-position 0.2s;
}

.photo_bar_image:hover {
    background-size:140px;
    background-position: -5px -5px;
}

<section id='photo_bar'>
    <a class='photo_bar_image'></a>
    <a class='photo_bar_image'></a>
    <a class='photo_bar_image'></a>
</section>

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 image appears smaller than its actual size

I'm having an issue with an image control that is supposed to display a logo on my webpage. The image itself is 500 x 500 pixels, however, when it appears on the screen, the control automatically shrinks it down to 19x20. I've been struggling to ...

What could be causing my HTML5 video control buttons to not function properly when using JavaScript?

I am currently working on a project that involves integrating external HTML buttons with a <video> element to control playback functions such as play/pause, rewind slow, rewind fast, and fast forward using JavaScript. Although I have successfully pos ...

Expanding <a> element to cover the entire <li> container

Take a look at this straightforward menu layout: <ul id="menu"> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> </ul> I'm looking to expand the <a> element so that it ...

Switch input trigger for immediate page refresh rather than standard input clearing

I want to customize how the clear input option functions. Normally, when you click on the X clear button, it clears the search input field. Instead of clearing the search input, I would like the clear button to trigger a page reload. This is the X button ...

Running a JavaScript function within a designated div element

I'm currently facing an issue with executing a javascript function - onload only in a specific div. I seem to be stuck on this problem, so if anyone could offer some assistance, I would greatly appreciate it. Thank you very much in advance! functio ...

Displaying only the div after the link from a table where all divs are shown using jQuery

I'm struggling to figure out how to select the immediate div inside each td and properly load up the page. Each link seems to toggle every hidden div on the page! The table contains hundreds of rows, with each row featuring a visible part - a link - ...

The contact form is encroaching on the footer

The issue arises when the contact form overlaps with the footer. When testing the code on Codepen, the styles are correctly linked and working for everything except the contact form. I have attempted adjusting the padding, bottom position, etc., but nothin ...

What is the best way to apply background color to match the height of the parent element?

When creating cards, I encounter a challenging issue. I am struggling to fill the background-color of the entire box content as I am new to HTML and CSS and unsure how to achieve this. Below are my codes. .box-container1 { display: flex; justify-con ...

What is the best way to exclude the "table" property from a button inside a row of a table?

I'm currently working with bootstrap and have implemented a table with the property "table" to create a light background for the data pulled from a database. The design looks great, except for when I try to insert a button in each row for editing purp ...

What is a method to test a website through automation without physically accessing it?

Although I have been using the Selenium web driver to test websites and obtain results, I now require a method to retrieve these results without actually opening any web pages. After conducting some research, I discovered that Selenium is unable to fulfill ...

Getting two <div> elements to float below one another can be achieved by utilizing the CSS property "float

Can someone please tell me the trick to floating one element below another on the same side? I want them both to float but be positioned under each other. Thank you in advance. ...

The audio.play() function on IOS 10 mobile devices is experiencing inconsistent performance

Check out my code below: $(document).on('click', 'div.play',function () { play = $(this); var stop = $('.stop'); contentId = play.attr('id'); nexttrack = nexttrackPlay(play); if(!play.parent().hasClass('stop&a ...

Converting an array to an HTML form and then executing a submit function

I am feeling a bit overwhelmed because my knowledge of PHP is quite basic, but I am trying to learn as I go. Within a custom Wordpress plugin, there is a PHP function that looks like this: $pool->get_leagues( true ); This function returns an array co ...

Exploring the Potential of JSP in Form Submissions

Here's a OCWCD question that I encountered: <form action="sendOrder.jsp"> <input type="text" name="creditCard"> <input type="text" name="expirationDate"> <input type="submit"/> </form> The question based on the ...

"Adding a class with jQuery on a selected tab and removing it when another tab is clicked

I have 3 different tabs named Monthly, Bi-monthly, and Weekly. The user can set one of these as their default payroll period, causing that tab to become active. I was able to achieve this functionality by utilizing the following code within the <script& ...

Clicking on an item causes it to move to the following line

Whenever I click on the third (bottom) line in the pagination block, the number item 30 keeps jumping to the next line. You can see it happening here. This issue only occurs in the Chrome browser. It seems like there might be a problem with the CSS. Can ...

Steps to display the datatable footer on the printed page

I am having trouble understanding the solutions provided for my table query. The current table setup is as follows: <table class="table table-bordered make_datatable"> <thead> <tr> <th>SL No</th> ...

When an element with a border attribute is hovered over, it shifts position

When I hover over an li-element, I want to apply borders at the top and bottom. Here's the code snippet: #overview li:hover { background: rgb(31, 31, 31); border-top: 1px solid white; border-bottom: 1px solid white; } Check out this JSFi ...

What's the best way to add click functionality to a bootstrap 5 card

I am currently learning Bootstrap 5, html, and CSS. I am using these technologies to develop a website and implementing Bootstrap 5 to create cards. I wanted to make these cards clickable so that they can redirect users to another page on the website. Howe ...

Unable to successfully implement the CSS not selector

My webpage's code was created through the use of Wordpress. <div class="header-main"> <h1 class="site-title"><a href="http://wp-themes.com/" rel="home">Theme Preview</a></h1> <div class="searc ...