Creating evenly spaced columns within a structure

Is there a way to create 3 equal columns in HTML5 without using tables? I'm having trouble achieving the desired result:

https://i.sstatic.net/AJIA3.png

The issue is that one of the columns doesn't look like the other two, even though they all have the same CSS applied to them.

https://i.sstatic.net/fb2vl.png

Any ideas on how to fix this? I am currently using a Bootstrap template for this website.

#refGan {
  display: inline-block;
  width: 193px;
  background-color: #F2F2F2;
  height: 378px;
  margin-right: 90px;
}

#refGan img {
  margin-left: auto;
  margin-right: auto;
  display: block;
  margin-bottom: 20px;
}

#refGan h3 {
  font-family: Miso;
  text-align: center;
  color: #A53D3E;
  font-weight: bold;
}

#refGan hr {
  width: 30px;
  position: center;
  color: #f00;
  background-color: #A53D3E;
  height: 5px;
}

#refGan p {
  font-family: 'Varela Round', sans-serif;
  font-size: 15px;
  color: black;
}

#refGan label {
  float: left;
  background: url(../pictures/button.png);
  background-repeat: no-repeat;
  background-size: 129px 30px;
  font-size: 12px;
}
<section id="refGan">
  <h3>Romance</h3>
  <hr>
  <div><img src="pictures/romantic anime.jpg" width="173" height="99" /></div>
  <p>
    This genre focuses on couples and love stories. It's very popular among young girls and has a special name in Japan: "Shoujo".
  </p>
  <label>
                        Recommended Shows
                    </label>
</section>
<section id="refGan">
  <h3>
    Action
  </h3>
  <hr>
  <div><img src="pictures/action anime.jpg" width="173" height="99" /></div>
  <p>
    A classic genre that usually combines martial arts and a central hero. It's very popular among young boys and has a special name in Japan: "Shounen".
  </p>
  <label>
                        Recommended Shows
                    </label>
</section>
<section id="refGan" class="marcoCol">
  <h3>Adventure</h3>
  <hr>
  <div><img src="pictures/adventure anime.jpg" width="173" height="99" /></div>
  <p>
    The genre known by everyone! It even reaches countries beyond Japan. Includes series like: Heidi and Nils Holgersson. What characterizes it, of course, are the adventures of the main hero.
  </p>
  <label>
                        Recommended Shows
                    </label>
</section>

Answer №1

Wrapping your sections in a div

 <div style="display: flex;">

This solution should resolve your issue, and I have also made additional adjustments to ensure responsiveness. By doing so, you won't need to hard code widths and margins.

#refGan {
    display: inline-block;
    width: 30%;
    background-color: #F2F2F2;
    height: 378px;
}

#refGan img {
    margin-left: auto;
    margin-right: auto;
    display: block;
    margin-bottom:20px;
}

#refGan h3 {
    font-family: Miso;
    text-align: center;
    color: #A53D3E;
    font-weight: bold;
}
#refGan hr{
    width: 30px;
    position: center;
    color: #f00;
    background-color: #A53D3E;
    height: 5px;
}
#refGan p{
    font-family: 'Varela Round', sans-serif;
    font-size: 15px;
    color: black;
}

#refGan label {
    float: left;
    background: url(../pictures/button.png);
    background-repeat: no-repeat;
    background-size: 129px 30px;
    font-size: 12px;
}
 <div style="display: flex;justify-content: space-around;">
<section id="refGan">
<h3>רומנטיקה</h3>
<hr>
<div><img src="pictures/romantic anime.jpg" width="173" height="99" /></div>
<p>
זה בדיוק איך שזה נשמע. בסדרות מסוג זה העלילה היא סביב זוג שמתאהבים. הז'אנר הזה מאוד פופולארי בקרב נערות צעירות וביפנית יש לו שם מיוחד: "שוג'ו".
</p>
<label>
לסדרות מומלצות
</label>

</section>
<section id="refGan">
<h3>
אקשן
</h3>
<hr>
<div><img src="pictures/action anime.jpg" width="173" height="99" /></div>
<p>
ז'אנר קלאסי שמשלב בדרך כלל אומנויות לחימה וגיבור מרכזי אחד. הז'אנר הזה מאוד פופולארי בקרב נערים צעירים וביפנית יש לו שם מיוחד: "שונן".
</p>
<label>
לסדרות מומלצות
</label>
</section>
<section id="refGan" class="marcoCol">
<h3>הרפתקאות</h3>
<hr>
<div><img src="pictures/adventure anime.jpg" width="173" height="99" /></div>
<p>
הז'אנר המוכר מכולם! הוא אפילו חדר למדינות מעבר ליפן. כולל בתוכו סדרות כמו: הלב (מרקו) ונילס הולגרסון. מה שמאפיין אותו, כמובן, זה ההרפתקאות של הגיבור הראשי.
</p>
<label>
לסדרות מומלצות
</label>
</section>
</div>

Answer №2

For those using bootstrap make sure to replace your HTML with:

<div class="container">
<section id="refGan" class="float-left col-xs-12 col-lg-4">
                <h3>Romance</h3>
                <hr>
                <div><img src="pictures/romantic anime.jpg" width="173" height="99" /></div>
                <p>
                    This genre revolves around couples falling in love. It is very popular among young girls and is called "Shoujo" in Japanese.
                </p>
                <label>
                    Recommended series
                </label>
            </section>
            <section id="refGan" class="float-left col-xs-12 col-lg-4">
                <h3>Action</h3>
                <hr>
                <div><img src="pictures/action anime.jpg" width="173" height="99" /></div>
                <p>
                    A classic genre that usually combines martial arts and a central hero. It is very popular among young boys and is called "Shounen" in Japanese.
                </p>
                <label>
                    Recommended series
                </label>
            </section>
            <section id="refGan" class="marcoCol float-left col-xs-12 col-lg-4">
                <h3>Adventure</h3>
                <hr>
                <div><img src="pictures/adventure anime.jpg" width="173" height="99" /></div>
                <p>
                    The most recognized genre of all! It has even crossed borders into countries beyond Japan, including series like Marco and Nils Holgersson. What defines it, of course, is the adventures of the main hero.
                </p>
                <label>
                    Recommended series
                </label>
            </section>
        </div>

Make sure to delete this CSS code:

#refGan {
float: left;
width: 25%;
background-color: #F2F2F2;
height: 478px;
margin: 50px;

}

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 process for choosing corresponding values in jQuery?

Hello, I am a beginner in programming and I am currently working on developing a word guessing game. Here is the code I have written so far: The (letter) represents the key being typed by the player Var compareLetters = $('.letter') represents ...

Should I use a tooltip or a pop-up for the tablet version?

I'm currently working on a web application that involves presenting 10 questions, each with 3 possible answers. For each answer, I require a tooltip or popover that provides guidance. While I have attempted to use tooltips and popovers, there is an is ...

How to customize JavaFx context menu appearance using CSS to achieve a full-width background color

I am trying to customize my context menu, but I'm having trouble with the white space between the menu item and the context menu border. Here is an example: view the rendered context menu with CSS styles What I want is for the color to fill the entir ...

Failing to draw an image on a blank canvas

I'm having trouble with my canvas. I want to clear it and then redraw it 30 pixels to the left on the x axis. However, when I try running the code, the canvas clears but the new image is not drawn. If I remove the "clearRect" function, the images are ...

Minimum width of Angular Material's mat-menu

I am looking to create a compact Material mat-menu using Angular 15. Below is the code I have: <mat-menu #flagMenu="matMenu"> <button mat-menu-item> <img src="assets/flags/en.png" class="flag"/> ...

The example in the MUI x-data-grid documentation always seems to fall short of expectations

I followed the code from the material-ui library documentation located at this link: https://mui.com/x/react-data-grid/layout/#flex-layout My aim is to set up a flex layout on my project, I went through the steps mentioned in the documentation but keep ...

Style.css remains invisible to NetBeans

My webapp is built using Servlets and JSP. However, I am currently facing an issue with directing NetBeans to my style.css file. Whenever the stylesheet is placed in WEB-INF or META-INF or even outside them within the Web Pages directory, everything func ...

Using JQuery, retain only the initial N elements in a list and discard the rest

I'm looking to streamline a list of items in the DOM by keeping only the first N items, ideally through the use of slice and remove methods. Could someone provide me with the JQuery syntax for removing items that come after the first N in the list? ...

Retrieve data from a collection by utilizing ng-repeat

I need help implementing a select interface on my website. Users will be able to choose a site, and then the associated country where the site is available will be displayed. To do this, I have a list of sites with information like their names and the co ...

I am interested in incorporating a delete button within my Angular application

I am working on an Angular App and I need to implement a remove button for a div element. Currently, I have an add button function in my ts file: uploads = []; addUp() { this.uploads.push(this.uploads.length); } I attempted to create the remove b ...

Is it possible to modify an input using a specific code?

Is it possible to dynamically change the value of a form input based on specific codes entered in another input without using PHP? For example, when a user enters "HFS73H" into one input, the value of another input changes to "John" - and if a different ...

Using jQuery to trigger a Bootstrap modal when a button is clicked

I've been attempting a simple task, but it appears to be unsuccessful. I'm trying to handle the click event of a button inside a bootstrap modal, and so far, nothing happens when clicking the button. My guess is that my jQuery selector for select ...

The image is exceeding the boundaries of its parent element, even though a height has been specified

I need assistance with aligning an image inside a div that should take the height of its parent div, specifically the .hero class. Despite setting the image's height to 100%, it still extends beyond the parent div and doesn't adhere to the specif ...

The functionality of the tree grid bootstrap is not functioning properly when it is dynamically generated, but it works seamlessly when implemented statically

The code below functions correctly and provides the expected output. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TreeView_Table_Project.WebForm1" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/ ...

AngularJS Multiple Select fails to display preselected options

This morning, I dedicated a significant amount of time to finding a solution for assigning multiple values to an entity on my form. The scenario is as follows: I have an Entity named QualityData that can have various MechanismIdentifiers. After brainstor ...

What is the best way to create a multi-line title within a div element?

Is there a way to make the div tag display multiple lines in a tool-tip on mouse hover instead of just one line? Here is the code I am currently using: <div title="Have a nice<br />day">blah</div> ...

Static Sidebar integrated with Twitter Bootstrap version 2.3.5

Currently, I am in the process of learning how to incorporate a fixed sidebar using Twitter Bootstrap 2.3.5. Below is a snippet of the code I have been working on: <div class="container"> <div class="row"> <div class="span4" id="sid ...

I am interested in using a loop in Angular to highlight my div element

Enhancing my comprehension regarding the mentioned images. If I don't select anything within the div property, the default style (css) should appear like this, at least when one div is selected. However, the issue arises when unable to select. This ...

Having trouble retrieving the image from the /var/www/efs/image/ directory using the html <img src> tag

Currently, I am facing a challenge in my project where I am trying to retrieve an image based on the users ID. The image is stored in the /var/www/efs/image folder. I attempted to specify the directory using the following code: <img src={"/var/www/ ...

Tips for switching out images depending on the time of day

Currently, I have a script that dynamically changes the background color of my webpage based on the time of day. However, I am facing issues trying to implement a similar functionality for replacing an image source. The current code is also time zone-based ...