How come the 'title' section isn't moving to the bottom as expected?

I'm having trouble aligning my title at the bottom, despite my best efforts. I can't figure out what's causing it to not go to the bottom. Could it be an issue with my HTML blocks or do I need a specific CSS property?

I attempted the following:

.service .title {
  background-color: red;
  text-align: center;
  font-size: 40px;
  display: block;
}

Here is a snippet of the HTML code:

<!-- Service Start -->
     <div class="service">
        <div class="t-container">
            <div class="section-header">
              <p>my first title a</p>
            </div>
        </div>
      <div class="title">second titre</div>
    </div>
<!-- Service End -->

Your assistance and time are greatly appreciated in resolving this issue.

Answer №1

Let's analyze the components of this issue.

The .about block spans the full width of the page, but its content is floated, causing a disruption in the layout. Upon inspecting the DOM nodes using your browser's developer tools, you'll notice that the height of the .about div is zero pixels, resulting in content overflowing outside the boundaries due to the floating element.

This leads to a zero-height div at the top of the page followed by a title with a red background below it. When an element has zero height and something lies below it, the latter also appears at the top of the page.

To address this issue, you can add a clearfix to the about section:

.about::after { /* Updated Code */
  content: '';
  display: table;
  clear: both;
}

/*******************************/
/********** About CSS **********/
/*******************************/

.about {
  position: relative;
  width: 100%;
}


.about .container {
  width: 50%;
  float: right;
  padding: 70px 30px 0px 30px;
}
... [Truncated for brevity] ... 


Okay, now we've moved past the top section, but the title in the service section is still not positioned beneath other content because of the .t-container being floated to the right.

A simple fix would be to apply the same styles from .t-container to the title element, resolving the issue (even though you may need to adjust padding as needed).

.about::after { /* Updated Code */
  content: '';
  display: table;
  clear: both;
}

.service .title {
  float: right;
  width: 50%;
  padding: 10px 30px 40px 30px;
}
... [Truncated for brevity] ...


A more optimal solution would involve reviewing your CSS approach. Consider using display: flex on the about section instead of floats to handle the zero-height issue. You can then remove floats in the service section and utilize margin-left: auto to align elements to the right while preserving document flow.

After making these adjustments, you may need to fine-tune individual spacings to achieve the desired layout.

/*******************************/
/********** About CSS **********/
/*******************************/

.about {
  position: relative;
  width: 100%;
  display: flex; 
  flex-direction: row-reverse; 
}
... [Truncated for brevity] ...

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

Removing Borders from HTML Tables

I am struggling to eliminate the border of a table within a gridview. The table is located inside the itemtemplate, and I can't figure out how to remove the border. Can someone please assist me with this? Thank you. Shown below is the code I am worki ...

What methods can be used to determine the origin of a tab activation?

I am currently working on a website that features both horizontal and vertical tabs in the main menu. Upon page reload, the first horizontal and vertical tabs are active by default. When I switch between the horizontal tabs, the content of the vertical tab ...

Automate the login process for a website and programmatically fill out and submit a form

I am currently trying to automate the login process on Skype's website using Selenium in C#. Everything goes smoothly until I reach the password field, which seems to be elusive to Selenium. I have tried various methods to locate the password field bu ...

Clicking on the menu in mobile view will cause it to slide upward

I have implemented sticky.js on my website and it is working well. However, when I resize the browser to mobile view and click the main menu button, it goes up and I am unable to close it. I have to scroll up to see it again. How can I make it stick to the ...

"PHP echo problem: Why isn't my simple echo statement

I'm delving into the world of PHP and decided to test my skills with an example I found on http://www.w3schools.com/. <!DOCTYPE html> <html> <body> <h1>A Header</h1> <?php echo "My first PHP script!"; ?> </body ...

Is there a way to retrieve the immediate children of all elements using CSS selectors in Selenium?

Although I attempted to utilize the ">" syntax, selenium does not seem to accept it. I am aware that Xpath can be used to obtain what I need, however our project exclusively utilizes CSS selectors. My goal is to create a list containing only the immedi ...

What is the best way to retrieve a value from a database and display it in a radio

Can you help me figure out how to implement this functionality? I have a database with a "boolean" field that stores 0 or 1 values. On an HTML page, there is a radioButton with options for OK or NO. I need to dynamically load the boolean value from the dat ...

Prevent horizontal HTML scrolling while displaying a layer

I am currently working with a .layer div element that darkens the page to highlight a modal. However, I have encountered an issue where upon triggering the event, the div does not occupy 100% of the screen and the original browser scroll bar disappears. I ...

Tips for implementing a hash map in JavaScript for seamless looping and deletion operations

I attempted to build a hashtable in JavaScript var map ={}; // the key is string values that I'm unsure about when I want to access // values are objects I am looking to iterate through the contents of the map. I would like to remove a specific p ...

Change the position of the div within the DOM

Looking to transfer a specific div ID to a different part of the DOM. <div id="portfolio"></div> Is this the correct code to utilize .html()? $(".text").click(function() { $("#portfolio").html($(this).next(".text1").html()); $(this). ...

Create a unique margin using CSS only that will appear at the bottom of a flex-row container that scrolls

I'm trying to create a horizontal scroller with margins between each item and consistent margins at both ends. However, I'm noticing that the margin at the end of the container seems to be disappearing somehow. Is there a way to maintain the mar ...

Show the TEXT in the upper right corner

I'm currently using bootstrap CSS. I have a header page where all the page links are displayed, and I want to show the LOGGED IN USER'S NAME IN THE TOP RIGHT CORNER. <li class="nav-item"><a class="nav-link text-dark"& ...

Create circles with a variety of different colors on the canvas

I need assistance with creating an animation where circles move from right to left on a canvas. The colors of the circles are randomly selected using a function. Currently, I have a fiddle where a single circle moves from right to left, changing color ever ...

Tips on inserting space in materialize css?

After reviewing the documents, I couldn't find any answers to my questions. Is there a way to create some space between the buttons? Currently, they are positioned right next to each other. Thank you! import React from "react"; import { connect } fro ...

Scrolling Vertically using WinJS ListView

Is it possible to achieve vertical scrolling in a ListView using HTML/JS for Windows 8 applications with WinJS? I successfully created a Windows 8 app with XAML/C# that utilizes a ListView for vertical scrolling. However, when attempting to replicate the ...

Display one table when clicked and hide the others

Within the structure of my webpage, I have numerous tables that follow a similar format but contain distinct content. Initially, all these tables are hidden from view. My goal is to design a functionality where clicking on a specific button will unveil onl ...

choose exclusively the text within the elementor navigation menu

I've been tinkering with this issue for a few hours now. I have a vertical Elementor navigation menu and I'd like to add a hover effect to it. So far, I can only select the entire column and apply the effect to that, not just the length of the t ...

What is the best way to format specific text as bold within an input text field?

I am attempting to make certain text bold within an input text field. However, I'm uncertain about how to achieve this because HTML code is not recognized inside a text field. Therefore, using <b> will not be effective. Is there a way to bold sp ...

select specific region within image

I'm currently working on cropping an image and sending the cropped data to the server side. To achieve this, I am utilizing the imgareaselect plugin. While I am able to obtain the coordinates of the selection, I am facing challenges in actually croppi ...

What is the best method for swapping out an iframe with a div using Javascript?

Having an issue with loading an external HTML page into an iFrame on my website. Currently facing two main problems: The height of the iFrame is fixed, but I need it to adjust based on the content's height. The content inside the iFrame does not inh ...