Solution 1 :

You could use margin:

import React from "react";
import "./styles.css";

export default function App() {  
  const style3 = {
    height: "75px",
    marginTop: 'auto'
  };
  return (
    <div className="App">
      <div style={style3}>CSS Flexbox</div>
    </div>
  );
}

Or align-self:

import React from "react";
import "./styles.css";

export default function App() {  
  const style3 = {
    height: "75px",
    alignSelf: 'flex-end'
  };
  return (
    <div className="App">
      <div style={style3}>CSS Flexbox</div>
    </div>
  );
}

Solution 2 :

I noticed you mentioned the div has lots of other information in a more complicated example. I would highly recommend trying out css grid if you haven’t already. It allows you to structure the items on your screen very easily.

Here’s an example using grid to create the ‘holy grail layout’ which is by no means the best example but it shows how easy it is to structure divs in different areas of the screen.

https://codepen.io/frazermg/pen/bXbXOR?editors=1100

.container {
  display: grid;
  grid-template-areas: 'header header header header'
                       'left content content right'
                       'left content content right'
                       'footer footer footer footer';
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(30vh, auto);
}

.header {
  background-color: blue;
  grid-area: header;
}

.left {
  background-color: green;
  grid-area: left;
}

.content {
  background-color: #eee;
  grid-area: content;
}

.right {
  background-color: pink;
  grid-area: right;
}

.footer {
  background-color: orange;
  grid-area: footer;
}
<div class="container">
  <div class="header"></div>
  <div class="left"></div>
  <div class="content"></div>
  <div class="right"></div>  
  <div class="footer"></div>
</div>

Here is an example of nested grids:

https://codepen.io/frazermg/pen/ZgEwVd

This website is very useful for all things css, especially flexbox and grid.
https://css-tricks.com/snippets/css/complete-guide-grid/

I hope this can help you!

Solution 3 :

What about simply style any span or component with text inside a div like this:

... style={{position:"absolute",bottom:"0px"}} ...

Problem :

How can I place text at the bottom of a div in plain old React (not React Native)?

In html, you can place text at the bottom of a div by using

vertical-align: text-bottom;

In React Native, it looks like you place text at the bottom of a div by using

textAlignVertical: "bottom",

Is there a simple way to place text at the bottom of a div in plain old React?
The only method I got to work so far is is to use Flexbox.

import React from "react";
import "./styles.css";

export default function App() {  
  const style3 = {
    height: "75px",
    display: "flex",
    justifyContent: "flex-end",
    alignItems: "flex-end",
  };
  return (
    <div className="App">
      <div style={style3}>CSS Flexbox</div>
    </div>
  );
}

Codesandbox


Edit: This is a simplified example. What I really need is a div with items in several different spots, and text on the bottom.


Edit: In both HTML and React, vertical-align: text-bottom; does not move text to the bottom of a div. It only shifts the text down a little bit to the bottom of where the text would normally be. So in both HTML and React, it can be used to shift text down a little for a subscript. But in both HTML and React, it can’t be used to shift text way down to the bottom of a div.

Comments

Comment posted by Alexander Staroselsky

Sounds like you were able to achieve the goal using flexbox. Are you experiencing other issues with using the flexbox approach?

Comment posted by Dan Cron

It works fine. But maybe there’s a more simple way to do it? If React Native and HTML has a simple way to do it, then why doesn’t plain old React? Did I make a mistake somewhere? Also, if this functionality is really only in React Native, it would be nice to have that information somewhere on stackoverflow.

Comment posted by Hamms

You can use the exact same CSS in React as you can in HTML; in this case, you would just need to apply the style

Comment posted by Dan Cron

@Hamms – Check my Codesandbox example. I couldn’t get

Comment posted by Dan Cron

@Hamms – I think I finally understand what you’re saying.

Comment posted by Dan Cron

marginTop: ‘auto’ is certainly simple. Thanks. But I don’t think that’s exactly what I’m looking for. I simplified the example for stackoverflow, but in the real complicated example, the div has lots of other information all over the place, and some text on the bottom. Would the margin mess up the other information in the div? I’ll edit the question. I guess I’ll use Flexbox unless I find something more simple. But “alignSelf: ‘flex-end'” didn’t give me exactly what I wanted.

Comment posted by Travis James

marginTop: ‘auto’ is just going to take the excess margin available and put it at the top of your text div, so if you want to push your text down to the bottom of the available space it will do that.

By