How to position an empty Div next to images

I am currently working on a project to familiarize myself with Japanese Hiagana. I plan to incorporate more images and eventually sound into the post. To reduce the number of images used, I attempted to replace empty .pngs with a div element. However, I am having difficulty aligning it with the rest of the images. I suspect there may be an issue in my code, but I am unsure how to correct it or if there is an alternative approach I should consider. Any assistance you can provide would be greatly appreciated!

You can view the page here:

<style>
.container {
position: relative;
width: 645px;
margin: 0 auto;
text-align:center;
}

.miniature {
    width: 6%;
    border: 1px solid grey;
    margin: 5px;
}

.miniaturex {
    height: 42px;
    width: 6%;
    border: 1px solid red;
    margin: 5px; 
}

</style> 

The miniaturex element is the red square on the linked page, and I am aiming to align it with the other images if possible.

Below is an example of my current code:

<div class="container">

<img class="miniature" src="https://lh5.googleusercontent.com/-rMwJbjg8x6I/VRdR9hUt5nI/AAAAAAAACJg/6gs2p1iOtm8/w60-h65-no/ha.png" />

<img class="miniature" src="https://lh5.googleusercontent.com/-EyXbRIMgfVI/VRdSBv9N-HI/AAAAAAAACJM/4QC48pQlpvo/w60-h65-no/na.png" />

<img class="miniature" src="https://lh5.googleusercontent.com/-vz3-ygDqmb0/VRdSFV5Qx4I/AAAAAAAACH0/td8fZFhbqsY/w60-h65-no/ta.png" />

<img class="miniature" src="https://lh5.googleusercontent.com/-ptiyMClrHPY/VRdSD0q7PxI/AAAAAAAACHU/HG8bUV5D6yQ/w60-h65-no/sa.png" />

<img class="miniature" src="https://lh5.googleusercontent.com/-RIuFcb3hvoE/VRdR-br6qFI/AAAAAAAACE4/7y1pcIHMuWU/w60-h65-no/ka.png" />

<img class="miniature" src="https://lh3.googleusercontent.com/-5hjR44OOz5c/VRdR9QG_maI/AAAAAAAACJg/FI8wRCLD1iI/w60-h65-no/a.png" />

<img class="miniature" src="https://lh3.googleusercontent.com/-TWp0rlJ4zXw/VRioHhaQw_I/AAAAAAAACJ8/AUWtqm8hpcU/w60-h65-no/x.png" />

</div> 

<div class="miniaturex"></div>

Thank you in advance for any assistance or suggestions you can provide.

Answer №1

The central alignment and image containment to 645 pixels are achieved by the Container div. However, the miniaturex div is positioned outside of the container, allowing it to bypass these styling rules.

To correct this, simply move the miniaturex div inside the container. Alternatively, you can duplicate the container div to encompass both divs. To improve clarity, consider consolidating shared settings between miniature and miniaturex, and then defining separate CSS rules for their unique attributes (such as setting the height specifically for miniaturex).

Answer №2

Removing text-align from the container would be a good idea. You could also try assigning a class to the images and then reference it like this: <img class="" /> to group specific images within the container.

<table>

<tr>

<td><img src="ra.png" />
<td><img src="ra.png" />
<td><img src="ra.png" />
<td><img src="ra.png" />
<td><img src="ra.png" />
<td><img src="ra.png" />
</tr>
<tr>
<td><img src="ra.png" />
<td><img src="ra.png" />
<td><img src="ra.png" />
<td><img src="ra.png" />
<td><img src="ra.png" />
<td><img src="ra.png" />
</tr>
<tr>
<td><img src="ra.png" />
<td><img src="ra.png" />
<td><img src="ra.png" />
<td><img src="ra.png" />
<td><img src="ra.png" />
<td><img src="ra.png" />
</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

Adjusting the background color of <tr> depending on the number of <tr> elements in the HTML using CSS

When working on my HTML page, I have utilized multiple <tr> tags with different bgcolor values such as: <tr bgcolor="#000000"> <tr bgcolor="#E5F1CC"> <tr bgcolor="#D30A0A"> <tr bgcolor="#656766"> I am aiming to assign unique ...

Using the fieldset element in AngularJS Material causes disruptions in my flex layout

My current issue can be illustrated through two code examples: The first example functions properly when the fieldset is not included. In the second example, including the fieldset causes the layout to extend beyond the window when there is long text (in ...

Troubleshooting the issue: Unable to shift a div to the left in a Rails app using jQuery and CSS when a mouseover event occurs

Hey there, I'm working on a div that contains a map. My goal is to have the width of the div change from 80% to 50% when a user hovers over it. This will create space on the right side for an image to appear. I've been looking up examples of jqu ...

Design a custom scrolling navigation bar for enhanced user experience

Struggling with web design as I develop a site in ASP.NET. I have a database full of courses, each with numerous modules. The challenge is creating a navigation bar that dynamically adjusts to accommodate the varying number of modules per course without o ...

Is there a way to automatically extend my content to fill the space on the page below the Material UI AppBar?

I am currently using React and Material UI React to develop my application. My goal is to implement the AppBar component with content underneath, without causing the entire page to scroll. I want the content to occupy the maximum remaining height and the f ...

When I click on a tab section to expand it, the carat arrows all point upwards. Only the arrows corresponding to the selected section should

click here for imageIt appears that there are four tabs, each with a click function on the carat icon. When I expand one tab, all carats point upwards instead of only the selected one appearing. accountSelection(account) { if (!this.selectedAccoun ...

What is the best method for incorporating a unique style to a v-dialog component in Vuetify following the most recent update?

I'm currently working on a project using vuetify, and I am facing an issue while trying to add a custom class to a v-dialog component. I have tried searching for information on how to do this, but it seems that the prop "content-class" has been deprec ...

Troubleshooting in Next.js 13: Issue with module not being found while trying to reference a package containing CSS

Currently working with Next.js version 13.4.2 and I have included an npm package that comes with CSS styles and fonts. The issue arises when trying to utilize one of the CSS files within my application. In the layout.tsx file, I imported the CSS file as fo ...

Prevent fixed div from overlapping with footer

I have been trying to find a solution for my fixed div that sticks to the bottom, but nothing seems to work. My goal is to have the div stop when it reaches the #footer section of the page. Visit the site The CSS currently in place gives the div the cla ...

Why are my cursor and my drawing line on opposite sides?

I've been working on a JavaScript drawing app, but I'm facing an issue where the drawn elements are not aligned with my cursor. The positioning seems off, especially when moving to the right or up on the canvas. As I move towards the furthest lef ...

Expanding Lists in Bootstrap 3: A Step-by-Step Guide

I have been experimenting with Bootstrap's Example accordion code, which can be accessed via this link: http://jsfiddle.net/qba2xgh6/18/ <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> <div class="panel ...

Select a color by inputting the type as "color" while leaving a space between the border and

I'm having an issue with the color input There seems to be a gap between the black border and the actual color, but I want to get rid of it #color-picker { border: 5px solid black; border-radius: 5px; width: 207px; height: 60px; padding: ...

Padding problem arises when you wrap an image with an anchor tag

I'm having an issue with a div containing an anchor-wrapped image, as there seems to be extra padding at the bottom of the div. How can I remove this? HTML: <div id="lineup"> <div class="line-up-click"> ...

What is the best way to preserve the allocated space in the DOM while utilizing CSS display:none?

I have explored the functionalities of display:none and visibility:hidden. However, I need to utilize display:none for a specific reason while still preserving the element's allocated space in the DOM to prevent any impact on adjacent elements. Is thi ...

Does Internet Explorer have a tool similar to Firebug for debugging websites?

Is there a tool similar to Firebug that is compatible with Internet Explorer? Edit I am currently using IE8, so I need a solution that works specifically with IE8. ...

Why is the toggle list not functioning properly following the JSON data load?

I attempted to create a color system management, but as a beginner, I find it quite challenging! My issue is: When I load my HTML page, everything works fine. However, when I click on the "li" element to load JSON, all my toggle elements stop working!!! ...

Creating a photo grid with consistent order is simple using flexbox

I'm currently working on an image grid that consists of 2 rows laid out horizontally. Initially, the first row contains 4 images while the second row has 2 images. Users should have the ability to add more images to the second row. The issue I am faci ...

Exploring jQuery: Techniques for Hovering, Changing, and Toggling Images

Currently, I am busy working on my project and I am attempting to achieve this by... I ideally want everything to be operational through click actions for each individual image, allowing them to have their unique "paper". I am aiming for a hover effect an ...

Creating a Functional Dropdown Menu with CSS and HTML

I recently created a test site without a drop-down menu, and here is how it looks: Check out my site here: Now, I want to add a simple drop-down menu for "serwery". Can anyone help me figure out what's wrong with my code? Here's the HTML: < ...

Modifying the color of the highlighted selection in a dropdown select box

Is it possible to change the blue highlight on this dropdown to gray? Check out this demo of a select box I am aiming to alter the highlight color to gray, can someone help me achieve this? select { border: 0; color: #EEE; background: transparen ...