What is the best way to align text directly beneath an h4 within a flexbox layout?

I'm attempting to get a p tag to align under an h4 with a slight indent, but it stubbornly refuses to move underneath, even after trying various CSS properties like float:left; or text-align:left;. The image below illustrates the issue: https://i.sstatic.net/iSRSL.png The text is floating above FreeCodeCamp instead of being positioned beneath it. Below is a snippet containing my code, which you can test:

.navbar-custom {
  ...
}
<link href="https: //cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
...
</div>

Answer №1

h4 and p should not have the flex-child property when flex-direction is set to row by default. You can wrap them together to maintain normal behavior:

For example:

.navbar-custom {
  background: #2C3E50;
  font-family: "Montserrat", "Helvetica Neue", Helvetica, Arial, sans-serif;
  text-transform: uppercase;
  font-weight: 700;
  border: none;
}
/* Rest of the CSS code goes here */
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="container">
  <div class="row">
    <div class="col-xs-6 col-sm-6 col-lg-6">
      <div class="box">
        <div class="icon">
          <div class="image"><i class="fa fa-graduation-cap"></i></div>
          <div class="info">
            <h3 class="title">Education</h3>
            <div style="display:flex;">
              <img src="image-url-here.png" alt="image-alt-text" id="edu-img">
              <div style="margin:auto;">
                <h4>School Name</h4>
                <p id="left">Description Here</p>
              </div>
            </div>;

           /* More HTML markup goes here */

            <div id="about-items">
              <img src="image-url-here.png" alt="image-alt-text" id="edu-img">
              <h4>Another School Name</h4>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="col-xs-6 col-sm-6 col-lg-6">
      <div class="box">
        <div class="icon">
          <div class="image"><i class="fa fa-check"></i></div>
          <div class="info">
            <h3 class="title">Other Things I've done</h3>
            <p>
              Sample text goes here.
            </p>;
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

flex-direction:column can be used with a fixed height for wrapping. For regular block behavior, it's recommended to wrap h4 and p together.

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

Automatically customizable CSS border thickness

Consider the following example of a div element: <div style="height: 10%; width: 20%; border: 1px solid black"> Div Content </div> The div above has its height and width specified in percentages. I would like the border width to adjust a ...

The position of the absolute item is not determined in relation to its container

I am experiencing an issue with two items in a 'relative' container. The problem arises when the 'absolute' item should be positioned relative to the container, but instead, it is being placed relative to the second 'static' ...

Random image generator using jQuery on the home page body

Hey guys, I'm working on a cool feature for my Wordpress site where a random background image loads every time the homepage is refreshed. Check out the code snippets below: First, here's what I have in my style sheet (style.css): body.home { ...

Experiencing Difficulty Personalizing Bootstrap Navigation Bar

I am attempting to add a circular border to a Font Awesome icon and this is the result: https://i.sstatic.net/28NFV.png This code snippet is for the page header. My goal is to enlarge the buttons when the screen size changes. .circle-icon { width: 80px; ...

Increase the font size of a div using CSS to make it appear larger

Utilizing a WYSIWYG-editor, I am creating content that I want to display with double font-size, without directly altering the HTML code. Here is an example of the HTML structure: <div id="contents"> <p style="text-align:center"> <spa ...

Instructions for incorporating numerous audio play buttons that cease playing one another

On my music website, I have an HTML list of tracks, some of which can be previewed with audio samples. I'm looking to add a play button (in the shape of a triangle) in front of each track so that visitors can click and listen to short audio samples. ...

Create an eye-catching table layout and a user-friendly search tool

Is there a way to include a Search Text Box inside a table layout, similar to the image provided? I tried adapting this example for my table Demo, but it doesn't meet my requirements. Some CSS modifications are needed to enhance... In the example ab ...

`Unable to display Bootstrap padding when using tabs`

Hello, I'm experiencing a strange issue with creating a form inside a container where the padding is not displaying. https://i.sstatic.net/v2AJI.png This is the HTML code: <div class="container-fluid"> <tabset tab-theme=" ...

Can you fill two dropdown menus with an array of choices?

I'm encountering an issue with using an array to populate two different select boxes. The first select box gets populated correctly, but when trying to add the same list to the second select box, it clears the first one and automatically selects the l ...

Adding a div after a specific child in a bootstrap grid

I've been searching tirelessly, but I just can't seem to crack this puzzle... In my Bootstrap grid, I'm faced with the challenge of injecting a div upon click after the row where the clicked div is located. For instance, I have a series of 5 ...

What is the best way to customize the primary Button style in Bootstrap?

Would you like the background-color to change when clicking on the radioButton? .btn-primary:hover, .btn-primary:active, .btn-primary:visited, .btn-primary:focus { background-color: black !important; color: white !important; } .btn-primary { colo ...

Avoid Scrolling within an iFrame in HTML with the Use of #

I have a menu loading in an iframe with links using # like http://<location>/page.html#part1. When I click inside the iframe, the entire page outside of the iframe scrolls to the location of #. How can I stop this from happening? I only want the me ...

Enhance the functionality of jqGrid by customizing key bindings for arrow and tab keys

In order to enhance my jqGrid functionality, I am seeking to implement the ability for users to press different keys for specific actions. For example, pressing Enter should save data (which is currently working fine), while pressing the left arrow key sho ...

Personalize the position of the v-select drop-down menu

I am currently working with the vuetify v-select component. The problem I am encountering is that instead of the dropdown opening downwards, I need it to open upwards since the dropdown is positioned at the bottom of the page which causes some of the dro ...

Position the title of the Bootstrap selectpicker field to the right

I utilized Creative Tim's Material Dashboard Pro to create a select field. My goal is to align both the select field and its options to the right. Currently, I have only been successful in aligning the options while the title and selected option rema ...

Whenever I include "border:0" in the styling of my hr element, a significant number of hr elements fail to appear on the screen

I have been experimenting with using hr elements to divide sections of my web page. Here is a snippet of the CSS code I am using: hr{ content: " "; display: block; height: .1px; width: 95%; margin:15px; background-color: #dfdfdf; ...

Having issues with nth-child? It seems like nth-of-type isn't working either

I am trying to change the color of all even titles from h2 to orange using nth-child. However, I seem to have made a mistake somewhere and can't figure out what it is... *{ font-size: 1em; } h2{ font-size: 1.5em } ...

Video playback in IE8 is not supported by mediaelement.js

I have gone through all the questions posted here, but none of them have solved my issue. Currently, the video loads and plays in Chrome, Safari, FF, and IE9, but not in IE8, which is the browser I need to support. You can see the page here. Despite tryi ...

Styling elements based on a condition with CSS

Is there a way to confirm the truthiness of a TypeScript variable using CSS? I am attempting to determine if I am on a particular page so that I can adjust the height accordingly. Appreciate any help! ...

Is it possible to change the CSS of a parent element using a child element?

My current challenge involves altering the background-color of a parent <td> element, without being able to directly modify the HTML structure. The software system utilized at my workplace strictly relies on SQL queries for data manipulation and gene ...