CSS/Jade/HTML: struggling to get boxes to align properly on the same line

I'm currently working with a Jade template that looks like this:

extends layout

block content
  h2 Characters and Portraits
  div(id="portraitsBox")
    - var portraits  = ["Clown-Fox", "Dragon-Bear", "Fish-Bear", "Deer-Wolf", "Salamander-Ant", "Side-Duck"];
    for filename in portraits
        - var url = "/images/portraits/" + filename.toLowerCase() + ".png"
        div(class="characterBox" id=filename)
          h3(class="characterName")= filename
          img(class="portrait" src= url)
  link(rel='stylesheet', href='/stylesheets/characters.css')

The CSS it's using is as follows:

#portraitsBox {
  border: 1px solid black;
  padding: 10px;
}

.characterBox {
  position: relative;
  padding: 5px;
  border: 1px solid black;
  width: 350px;
  display: inline;
}

.characterName {
  padding-top: 0px;
  width: 150px;
  font: Arial;
  text-align: center;
}

Everything seems to be fine without the display: inline property, but once I include it, it messes everything up. The result can be seen here:

And for some reason, the container div resizes itself to 169.9px wide! What could be causing this issue? I've checked for Bootstrap default stylings in Firebug, but there doesn't seem to be anything overriding my custom CSS (which is included in the extended layout file).

Answer №1

Are you seeking to achieve this outcome:

I'm a bit puzzled because you mentioned that disabling display inline should work fine, but when I tested it, the elements still appeared as block.

If the screenshot demonstrates your desired result, simply adjust the wrapper #portraitsBox to have a display property of flex.

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

Steps for creating a fade effect between two different elements when the mouse is interacting with one of them

I want to create a unique effect with an image in the background and a button above it. When the mouse hovers over the button, I want its opacity to decrease while the image's opacity increases simultaneously. I have experience applying fade effects ...

Troubleshooting problem with CRUD operations in MySQL, Express, React.js, and Node.js

Is there a way to post data from three input fields in a form to a MySQL database table using Axios? I have attempted multiple times but have been unsuccessful. Can someone provide the code for connecting to the database and inserting the query? //PostFo ...

"An error message stating 'Express: The body is not defined when

I'm encountering an issue while trying to extract data from a post request using express. Despite creating the request in Postman, the req.body appears empty (console.log displays 'req {}'). I have attempted various solutions and consulted s ...

How can I align two tags horizontally using HTML and CSS?

I've been diving into HTML and CSS lately and making some progress, but I've hit a snag. I'm trying to create a horizontal ul list with li elements on the same line at the top of the screen, similar to Stack Overflow's layout. Although ...

Is there a way to exclude the Unicode character from the first menu item while still utilizing it in the other items on my menu?

I have been working on customizing my menu by using the unicode character \25C6 to represent a black solid diamond as a spacer between labels. After searching for solutions on Stack Overflow, I attempted to implement the suggested method using the bef ...

Having trouble displaying SVG elements in Material UI

Currently, I am faced with an issue while trying to display a .svg file in the header of a drawer using Material-UI and create-react-app. Instead of the expected .svg image, all I see is a broken image rendering. Any assistance on resolving this problem ...

Position a Paper component in the center of a div

I'm having trouble centering my <Paper> element inside a div. Can anyone help me with this? I have placed both the <Paper> and <RaisedButton> elements inside the div and applied the following CSS: .timerArea { text-align: center; ...

Whenever I try to log in using axios and my credentials are incorrect, I don't receive any response back in the catch block

I cannot receive any response when calling the login API from Node.js. In the frontend, I am handling the catch as well. How do I retrieve the Invalid Credentials message from the backend API if the credentials do not match? The code for my backend logi ...

What could be causing the Multer error in my Express.js application when attempting to upload a file for the second time, even though the first time was successful?

Whenever I try to upload a single file, the code works flawlessly. However, if I attempt to upload another file, I encounter the following Multer error: Error code: 'LIMIT_UNEXPECTED_FILE', field: 'myFile', storageErrors: [] To succes ...

Bootstrap: Arrange multiple images horizontally within a row

I am trying to design a list item for a game that includes a background, an iconholder with an icon, a title, description, and up to three resources. I have been experimenting with Bootstrap and attempted using a container-fluid with an inner row but the i ...

I encountered an error while attempting to lint my code because ESLint was not configured to ignore the

Trying to set up eslint in a Next.js project, here is the file structure: .eslintignore .eslintrc.js .next .prettierrc .stylelintrc.js components forms modals modules node_modules In my .eslintignore file, I have added node_modules/*. When running eslint ...

Issue with Navigation menu dropdown not functioning properly on Angular version 12 with Bootstrap 5

I am attempting to integrate bootstrap with Angular through a CDN. Below is the content of my index.html file: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Laboratorio Sigma< ...

How does `var express = require('express');` differ from `var app = express();`?

Is it correct to declare var app = express; instead of var app = express(); since it was declared as a variable (object) above? Also, where is the express() function coming from? If it is from the express module, then should the third line be var app = ex ...

CSS transition effect to show content: display: block

After experimenting with different styles for another element, I added padding, height, and opacity to the div. However, there seems to be no transition effect with the current CSS code. Can anyone explain why? When a button is clicked, the class .show is ...

The newly created header in Node.js (res.header) is not showing up in Chrome browser

Recently, I've started learning JavaScript, Express, and NodeJS. I'm facing an issue while attempting to create a new header containing a token upon user login (as demonstrated in the login POST router below) // Login POST Router router.post(&ap ...

Selecting columns that do not exist in the Sequelize query may result in

Despite my simple creation process, Sequelize insists on selecting a column 'userId' that neither exists nor is being used. After performing some database checks and confirming everything is in order, Sequelize should proceed with the creation p ...

Using jQuery to store the last selected href/button in a cookie for easy retrieval

Recently, I've been working on a document that features a top navigation with 4 different links. Each time a link is clicked, a div right below it changes its size accordingly. My goal now is to implement the use of cookies to remember the last select ...

Adjust the alignment of the text to match the orientation of the image

When creating a layout with text and an image, I want them to be contained within a parent element that has a specified height, such as 100px. The text should adjust to the content, whether it's a short phrase or a lengthy paragraph, without a fixed ...

I possess both a minimum and maximum number; how can I effectively create an array containing n random numbers within

Given a minimum number of 10.5 and a maximum number of 29.75, the task is to generate an array within these two ranges with a specific length denoted by 'n'. While the function for generating the array is provided below, it is important to calcul ...

Can anyone help me with fixing the error message 'Cannot assign to read-only property 'exports' of the object' in React?

Recently, I decided to delve into the world of React and started building a simple app from scratch. However, I have run into an issue that is throwing the following error: Uncaught TypeError: Cannot assign to read-only property 'exports' of o ...