Home > Software design >  Get the 'card-title' to start just above a div
Get the 'card-title' to start just above a div

Time:12-28

I want the 'title' to start right above 'first yeah', the image should also start there enter image description here

I've tried several ways (and with some classes) but I haven't succeeded

The card code:

<div >
   <div  style="background-color: #706747;">
      <h1 >
         <p >
            <img src="/assets/logo.gif" alt="" width="60" height="48" >
            {{cosos}} title
         </p>
      </h1>
      <br>
      <div >
         <div >First flex item</div>
         <div >Second</div>
         <div >Third</div>
         <div >Final yup</div>
      </div>
   </div>
</div>

I'm using Bootstrap 5 for everything, I have no classes or styles of my own

CodePudding user response:

You can make use of the grid-layout of bootstrap to align the elements.

<html>
  <head>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
  </head>
  <body>
    <div >
   <div  style="background-color: #706747;">
      <h1 >
         <p >
          <div >
          <div >
          </div>
          <div >
           <img src="/assets/logo.gif" alt="" width="60" height="48" >
          </div>
          <div >
           <span id="title1"> fdasdstitle</span>
          </div>
      </div>
         </p>
      </h1>
      <br>
      <div >
         <div >First flex item</div>
         <div >Second</div>
         <div >Third</div>
         <div >Final yup</div>
      </div>
   </div>
</div>
  </body>
</html>

CodePudding user response:

Step 1: remove class justify-content-center and add p-2 after class card-title. Now you will see your logo.gif and title will align with first nav bar item.

Step 2: Add place-self: center; to the div with class card-body.

Step 3: Assign background-color: #706747; to the class card, remove from card-body div.

The updated HTML will be like this:

<div  style="background-color: #706747;">
  <div  style="place-self: center;">
    <h1 >
      <p >
        <img src="/assets/logo.gif" alt="" width="60" height="48" > {{cosos}} title
      </p>
    </h1>
    <div >
      <div >First flex item</div>
      <div >Second</div>
      <div >Third</div>
      <div >Final yup</div>
    </div>
  </div>
</div>

  • Related