What could be the reason for justify-self: flex-start not positioning the div at the bottom of a column?

I want to display a div in three levels: header, content, and footer. The content can vary in height and the footer should always be at the bottom. Here is how I have implemented it:

<div class="news-content-block">
    <div class="news-title">
        <a href="/link">
            {{ $news->title }}
        </a>
    </div>

    <div class="news-content-wrapper">
        <div class="news-content"> TEXT OF different length
        </div>
    </div>

    <div class="user-reactions-block-wrapper">
        FOOTER CONTENT
    </div>
</div>

Here are the styles I have defined:

.news-content-block{
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: start;
    padding: 20px;
}

.news-title {
    position: relative;
    width: 814px;
    height: 24px;
}

.news-content-wrapper {
}

.user-reactions-block-wrapper {
    display: flex;
    justify-self: flex-end;
    align-self:flex-start;
}

In the user-reactions-block-wrapper class, I have set

 display: flex;
 justify-self: flex-end;
                    

I expected this class to be at the bottom, but that was not the case...

After researching online, I came across this page: https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self

which mentions:

justify-self: flex-start; /* Equivalent to 'start'. Note that justify-self is ignored in Flexbox layouts. */
justify-self: flex-end; /* Equivalent to 'end'. Note that justify-self is ignored in Flexbox layouts. */

How can this issue be resolved?

Answer №1

To ensure proper alignment and sizing of your elements, you must first specify a specific height for the news-content-block element. Failure to do so will result in the height being automatically determined by its child elements. Additionally, adding flex:1 to the user-reactions-block-wrapper will set the height of the element to occupy the available space. By including align-items: flex-end, the content will align to the bottom as desired.

.news-content-block{
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: start;
    padding: 20px;
    height: 100vh;
    border: 1px solid black; /* added for reference points */
}

.news-title {
    position: relative;
    width: 814px;
    height: 24px;
}

.user-reactions-block-wrapper {
    display: flex;
  flex: 1;
  align-items: flex-end;
}
<div class="news-content-block">
    <div class="news-title">
        <a href="/link">
            {{ $news->title }}
        </a>
    </div>

    <div class="news-content-wrapper">
        <div class="news-content"> TEXT OF different length
        </div>
    </div>

    <div class="user-reactions-block-wrapper">
        FOOTER CONTENT
    </div>
</div>

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

When a child element within a flex container has a relative position, the flex direction column will be overridden and

I'm having trouble with the code snippet below. For the .container, I have set display:flex; flex-direction: column; in order to position my previous and next arrows before and after the container items. However, the flex direction does not change ...

I am having trouble with the Bootstrap 5 column not functioning properly within my design

Currently working on a project with Bootstrap, where I am trying to create a footer that looks like the one in the image below: https://i.stack.imgur.com/XIbDk.png Below is the HTML code snippet for my footer: <footer class="footer"> <div class ...

Awesome C# PDF Printing Solution [closed]

This question does not comply with our Q&A standards and guidelines. To maintain the integrity of our platform, we require answers to be factual, supported by references or expertise. However, this question may provoke debates, arguments, polls, or pro ...

Height of list items in image gallery does not automatically readjust

I'm facing an issue regarding the height of an li element. Check out this CodePen link for reference. <div class="row fp-gallery"> <ul class="large-block-grid-4 medium-block-grid-4 small-block-grid-2"> <li> <a href= ...

Is placing JavaScript on the lowest layer the best approach?

I'm facing a unique situation that I haven't encountered before and am unsure of how to address it. My website has a fixed top header and footer. On the left side, there is a Google Adsense ad in JavaScript. When scrolling down, the top header s ...

Replacing one <div> with another <div> using a clickable link within the divs

In one of my web pages, there is a div that I'll refer to as div1. Within this div, there is a link called 'Link1'. My goal is to click on Link1, triggering the replacement of div1 with div2. Inside div2 there will be another link, let&apos ...

Numerous changes using media queries

Is there a way to have separate transitions in media queries without duplicating code? @media screen and (min-width: 800px) { #div { transition: width 1s; } } #div { transition: height 1s; /* Overrides previous one :( */ } How can I a ...

Trouble with Displaying 3rd Level JQuery Dropdown Menu

Currently working on implementing a 3 level dropdown feature. I have been using a third-party responsive menu in Opencart and it's been working well. You can see a demo of it here: Unfortunately, Opencart does not natively support 3 level categories, ...

Displaying incorrect text format on a TextView using Html.fromHtml()

Within my application, there is a string that represents a mathematical expression: String s = "log<small><sub>(log<small><sub>(log<small><sub>3<small><sup>2</sup></small></sub></small&g ...

Container Based Absolute Positioning in Bootstrap

I am struggling with aligning text properly within a container. I want it to look like the image, but the text keeps ending up at the far right side of the page. Could you assist me in achieving this? Thank you! HTML: <header> <div class="c ...

Issues with SVG Image Mask in Firefox and IE: How to Fix Them

Creating a mask with a PNG (black circle, transparent background) and using -webkit-mask-image:url(images/mask.png) has been easy for browsers like Chrome. However, I've been encountering significant difficulties in getting the mask to display properl ...

Tips for positioning two elements side by side in an li element without needing to clear each time

I'm struggling with a stacked list that involves floating an image (icon) alongside text. The constant need to clear after each list item is becoming cumbersome. Anyone have any suggestions for making this more streamlined and tidy? <ul> < ...

What is the significance of the colon found within a VueJS/Vuetify/HTML component tag?

Incorporating Vuetify into my project has led me to this VueJS, Vuetify, or HTML inquiry. The component in question displays as follows: <v-list-tile v-for="item in menuItem.items" :key="item.type" :style="`background: ${item.colour}`" :h ...

Encountering issues with the hyperlink tag '<a>' in an HTML document

I've encountered an issue with the code on my HTML page: <body> <div align="center"> <a href="../index.html"> <img border="0" src="banner1.jpg" width="800" height="120" alt="Ecommerce Knowledge Base"> &l ...

Issue with mouseMove function not aligning correctly with object-fit:contain CSS property

My current code allows users to select a color from an image when hovering over the pixel with the mouse. However, I am encountering an issue where the colors do not map correctly when using object-fit: contain for the image. The script seems to be treatin ...

Switch off any other currently open divs

I'm currently exploring a way to automatically close other div's when I expand one. Check out my code snippet below: $( document ).ready(function() { $( ".faq-question" ).click(function() { $(this).toggleClass('open'); $(this ...

The submission of the form is not functioning correctly when triggered by JavaScript using a button

My website was designed using a CSS/HTML framework that has been seamlessly integrated into an ASP.NET site. Within a ContentPlaceHolder, I have implemented a basic login form. The unique aspect is that I am utilizing the onclick event of an image to subm ...

When I expand the accordion next to it, the accordion disappears, and it also vanishes when I close that accordion

After incorporating accordions into my site, I encountered a peculiar issue (as shown in this video): when I open one accordion, the adjacent accordion also opens unexpectedly. Similarly, closing one accordion causes its neighboring accordion to mysterious ...

Change the display, animate the elements within

Currently working on a landing page with a contentSwitcher and everything is functioning properly. However, I am interested in animating the contents sequentially to add some stylish flair. Take a look at the Test Landing Page for reference. If you observ ...

Javascript problem: Trouble with event.clientX position

I found a great resource on learning javascript at this website, I'm having trouble understanding the code snippets in function XY(e, v), specifically these two lines: event.clientX + document.documentElement.scrollLeft and event.clientY + document ...