Unable to stack a text element on top of another element with CSS

I am a novice looking to delve into the world of programming. Currently, I am immersing myself in learning HTML and CSS while embarking on my inaugural project. The task at hand involves creating a simple homepage for a local game store with the objective of honing my foundational skills and applying everything I have learned thus far.

The current challenge I am encountering pertains to the positioning of the <h1>Trabalhamos com as seguintes plataformas:</h1> element on line 35 ABOVE the logos within my list, rather than alongside them. While aware that we typically utilize 'display: flex' for this purpose, the actual outcome puzzles me. In an earlier iteration of this same project sans the aforementioned <h1> title, the logos were actually displayed BELOW the lorem ipsum text. Despite attempts to apply 'display: block' specifically to this <h1>, desired results remain elusive. Even after experimenting with a standalone <div> governed by its own rules distinct from the '.container' class, the layout fails to align correctly. Further efforts involving 'flex-direction: column', based on online research, proved fruitless. Being a beginner, uncertainty looms regarding whether or not I am employing the appropriate properties essential for achieving my goal. Any assistance would be deeply appreciated - not just in terms of providing a solution but also offering guidance on how to reach it and highlighting potential mistakes made along the way.

Presented below is the existing HTML and CSS code:

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

header {
  padding: 8px 0;
  background-color: black;
  color: white;
  background-image: url(./midia/banner-cobrinha-games.jpg);
  background-repeat: no-repeat;
  background-position: center;
}

header nav li {
  display: inline;
  margin-left: 16px;
  font-size: 18px;
}

header nav li a {
  color: white;
  text-decoration: none;
}

.container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

header .container,
section .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#logo {
  width: 175px;
}

#fachada {
  width: 60%;
  margin-right: 24px;
}

.brands img {
  height: 30px;
}

.brands li {
  display: inline-block;
  margin-right: 14px;
  margin-bottom: 14px;
}

section .container {
  align-items: flex-start;
}

section {
  padding: 24px 0;
}

h1 {
  display: block;
}
<header>
  <div class="container">
    <img src="./midia/cobrinha-games-logo.png" alt="Logo Cobrinha Games" id="logo">
    <nav>
      <ul>
        <li><a href="#">Sobre a Loja</a></li>
        <li><a href="#">Contato</a></li>
      </ul>
    </nav>
  </div>
</header>
<section id="sobre">
  <div class="container">
    <img src="./midia/foto-loja-cobrinha-games.png" alt="Foto da loja Cobrinha Games" id="fachada">
    <article>
      <h1>Sobre a Loja</h1>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic debitis iusto eum eaque nostrum, possimus, qui pariatur a dolor, quo reiciendis? Aspernatur eveniet illum tenetur quasi vitae fugiat maiores animi?</p>
      <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Laborum, laudantium iure ullam delectus quasi architecto cumque et corrupti? At voluptatum eligendi laborum sint voluptas molestiae fugiat esse doloribus obcaecati perferendis.</p>
      <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Corrupti officia dolores repellendus. Sequi voluptates eum, magnam blanditiis, deserunt sunt dolorem cupiditate velit fugiat officia rem? Quia voluptate eum architecto vitae.</p>
    </article>
  </div>
</section>
<section id="plataformas">
  <div class="container">
    <h1>Trabalhamos com as seguintes plataformas:</h1>
    <ul class="brands">
      <li><img src="./midia/psx.svg" alt="Logo Playstation"></li>
      <li><img src="./midia/ps2.svg" alt="Logo Playstation 2"></li>
      <li><img src="./midia/ps3.svg" alt="Logo Playstation 3"></li>
      <li><img src="./midia/ps4.svg" alt="Logo Playstation 4"></li>
      <li><img src="./midia/ps5.svg" alt="Logo Playstation 5"></li>
      <li><img src="./midia/xbox.svg" alt="Logo Xbox"></li>
      <li><img src="./midia/x360.svg" alt="Logo Xbox 360"></li>
      <li><img src="./midia/xone.svg" alt="Logo Xbox One"></li>
      <li><img src="./midia/xseries.svg" alt="Logo Xbox Series X/S"></li>
      <li><img src="./midia/n64.svg" alt="Logo Nintendo 64"></li>
      <li><img src="./midia/gamecube.svg" alt="Logo GameCube"></li>
      <li><img src="./midia/wii.svg" alt="Logo Nintendo Wii"></li>
      <li><img src="./midia/wii-u.svg" alt="Logo Nintendo Wii U"></li>
      <li><img src="./midia/switch.png" alt="Logo Nintendo Switch"></li>
      <li><img src="./midia/psp.png" alt="Logo Playstation Portable"></li>
      <li><img src="./midia/psvita.png" alt="Logo Playstation Vita"></li>
      <li><img src="./midia/gba.svg" alt="Logo Game Boy Advance"></li>
      <li><img src="./midia/nds.svg" alt="Logo Nintendo DS"></li>
      <li><img src="./midia/3ds.svg" alt="Logo Nintendo 3DS"></li>
    </ul>
  </div>
</section>

For access to the repository containing this particular project, kindly refer to the following link: https://github.com/rodriguesraph/curso_ebac_frontend/tree/projeto_1

Answer №1

If you applied the 'display: flex' property to the .container class, the items will be displayed next to each other. To reverse this effect, simply add the 'no-flex' class to the .container class and include the following CSS code.

.container.no-flex {
    display: block;
}
<section id="plataformas">
    <div class="container no-flex">
        <h1>We work with the following platforms:</h1>
        <ul class="brands">
          .....
        </ul>
    </div>
</section>

Answer №2

To arrange the elements vertically, simply apply the flex-direction: column; property.

Answer №3

Move the h1 tag to be outside of the div element. Here's an example:

    <section id="platforms">
      <h1>We work with the following platforms:</h1>
        <div class="container">

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

failure in data transmission causing upload issues

Is there a way for me to prevent the character > from causing issues? I have a combo box with an option listed below. I attempted to replace > with &gt;, but it still isn't uploading correctly. <select name="Category3" id="Category3"> ...

The search box does not trigger the Else statement when an invalid text is entered

ASP.NET Engine Upon entering an invalid User ID in the text box and clicking on search, instead of displaying "No Class found", the current output shows "Search Result". It appears that the else statement is not being executed as expected. HTML <div ...

Changing SVG containing image tags into HTML canvas

I'm attempting to convert an SVG file to an HTML canvas, and everything works perfectly until I introduce the image element in the SVG. When I include image elements, the canvg function stops working. Below is the code I used to convert the SVG to ca ...

Enhancing the Appearance of WooCommerce Product Descriptions

Having some trouble with my website . There are two descriptions on the "Product" page - one above the tabs and one inside the tabs. Trying to change the text color in the tab section to black, but when I adjust the body text color it affects both areas. I ...

Is it possible to protect assets aside from JavaScript in Nodewebkit?

After coming across a post about securing the source code in a node-webkit desktop application on Stack Overflow, I began contemplating ways to safeguard my font files. Would using a snapshot approach, similar to the one mentioned in the post, be a viable ...

Is there a way to hide overflow scroll bars with jquery ui's resizable feature until they are needed?

Here is a live example for reference: http://plnkr.co/edit/ivjvAZ?p=preview Combining jquery ui and angular, I have created a resizable directive for absolutely positioned divs. The issue at hand is that all the divs have scrollbars appearing constantly, ...

What are some ways to utilize symbol fonts such as marvosym within a web browser?

Are you looking to use special LaTeX fonts like \Pluto from marvosym in your web development projects? Wondering how to display this symbol with HTML / JavaScript / CSS without relying on an image? You can download the font from This symbol corresp ...

Javascript's second element does not trigger a click event with similar behavior

I'm currently facing an issue with displaying and hiding notification elements based on user interaction. My goal is to have multiple popup elements appear when the page loads. Then, when a user clicks the ".alert-close" element within one of the popu ...

Displaying a div and ensuring it remains visible upon clicking

$(document).ready(function() { $('#input').focusin(function() { if ($(this).val() != '') { $('#div').show(); } else { $('#div').hide(); } $('#input').keyup(function() { / ...

How can I use jQuery to internally modify the styling of an IFrame element?

I am facing a situation where I need to dynamically insert an iframe into a parent page (The domain is out of my control) using the following script... var _hf_iFrame = document.createElement("iframe"); _hf_iFrame.setAttribute("id", "_hf_iFrame"); _hf_iFr ...

Tips for maximizing the efficiency of a callback when utilizing the filter function in Primefaces for 'myDataTable'

Currently using Primefaces 5.1, and I've encountered a situation where I want to hide a table until after the filter is applied in Javascript. My initial thought was to simply set the css of the table to visibility:hidden;, followed by running the fol ...

`Certain browsers are experiencing issues with text overlay functionality.`

I have managed to successfully create the necessary code to incorporate an image with a child element containing text overlaying the image. However, this functionality does not appear to be working on Internet Explorer (IE), and I am struggling to find a C ...

tips for concealing bootstrap css hover/activate color when scrolling beyond the top

Looking for help with my Bootstrap HTML code: <nav> <ul> <li><a>1</a></li> <li class="active"><a href="#">2</a></li> <li><a>3</a></li> & ...

Text is being truncated in the title instead of moving to the next line

<View style={{ flexDirection: 'row', alignItems: 'center', height: 130, marginVertical: 10, overflow: 'hidden' }} > <Image sour ...

In the process of transforming my JavaScript code into JQuery

I'm struggling to convert my JavaScript code into jQuery, especially when it comes to calling the function for radio elements by name. The original JavaScript works fine, but I can't seem to get the jQuery version to work correctly. Index HTML ...

Uploading multiple files with unique IDs into a table

Currently, I am attempting to modify the code found at: This code functions perfectly with a single file input (and has been utilized in various projects without any issues). My specific requirement is to generate a table with a file input within each ro ...

Determining the Width of a DIV Dynamically with CSS or LESS Depending on the Number of Siblings

One of my challenges involves a parent DIV with a width set to 100%. Dynamically, this parent DIV is filled with numerous children DIVs. I am trying to calculate and assign their widths using only the calc method in CSS or LESS. This is because the flex ...

Send the image link as a parameter

I've been trying to pass an image link through two child components, but I'm having trouble. I added the link to the state and passed it down, but it doesn't work. Strangely, when I manually input the link in the child component, it works pe ...

Automatically numbering text boxes upon pressing the enter key

Is there a way to automatically number textboxes when I type "1" and hit enter in one of them? For example, if I have 3 textboxes and I type "1" in the first one, can the other textboxes be numbered as 2 and 3 accordingly? <input type="text&qu ...

Ways to avoid scrolling on a fixed element

Here is the HTML setup I have... body .top .content The issue I am facing is that when scrolling reaches the end of the ul in the .top element, the background starts to scroll. This can be quite disorienting and makes the site slow on tablets. Even ...