0

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 class="card border-dark">
   <div class="card-body" style="background-color: #706747;">
      <h1 class="card-title">
         <p class="text-body">
            <img src="/assets/logo.gif" alt="" width="60" height="48" class="d-inline-block">
            {{cosos}} title
         </p>
      </h1>
      <br>
      <div class="d-flex flex-nowrap bd-highlight justify-content-center">
         <div class="order-1 p-2 bd-highlight">First flex item</div>
         <div class="order-2 p-2 bd-highlight">Second</div>
         <div class="order-3 p-2 bd-highlight">Third</div>
         <div class="order-4 p-2 bd-highlight">Final yup</div>
      </div>
   </div>
</div>

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

2 Answers2

0

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

<html>
  <head>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
  </head>
  <body>
    <div class="card border-dark">
   <div class="card-body" style="background-color: #706747;">
      <h1 class="card-title">
         <p class="text-body">
          <div class="row">
          <div class="col-3">
          </div>
          <div class="col-2">
           <img src="/assets/logo.gif" alt="" width="60" height="48" >
          </div>
          <div class="col-7">
           <span id="title1"> fdasdstitle</span>
          </div>
      </div>
         </p>
      </h1>
      <br>
      <div class="d-flex flex-nowrap bd-highlight justify-content-center">
         <div class="order-1 p-2 bd-highlight">First flex item</div>
         <div class="order-2 p-2 bd-highlight">Second</div>
         <div class="order-3 p-2 bd-highlight">Third</div>
         <div class="order-4 p-2 bd-highlight">Final yup</div>
      </div>
   </div>
</div>
  </body>
</html>
Giriteja Bille
  • 168
  • 1
  • 13
  • In small views it works great, but in large resolutions (for example, my monitor is 1600x900) with the page in full-size, neither the logo nor the image can reach the first item. Although I varied and tried with the 'col-*', I did not achieve the result I was looking for –  Dec 28 '21 at 05:05
  • Have you tried by changing the col-lg and col-xl in your code? – Giriteja Bille Dec 28 '21 at 06:11
  • Yes, I tried it, I've been trying to vary it with the 'col-*' without luck –  Dec 29 '21 at 02:27
0

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 class="card border-dark" style="background-color: #706747;">
  <div class="card-body" style="place-self: center;">
    <h1 class="card-title p-2">
      <p class="text-body">
        <img src="/assets/logo.gif" alt="" width="60" height="48" class="d-inline-block"> {{cosos}} title
      </p>
    </h1>
    <div class="d-flex flex-nowrap bd-highlight ">
      <div class="order-1 p-2 bd-highlight">First flex item</div>
      <div class="order-2 p-2 bd-highlight">Second</div>
      <div class="order-3 p-2 bd-highlight">Third</div>
      <div class="order-4 p-2 bd-highlight">Final yup</div>
    </div>
  </div>
</div>
seantsang
  • 1,123
  • 2
  • 7
  • 20