How to have the two columns vertically aligned?












0














I have this code for a bootstrap jumbotron, however I would like to have the column at left with the h1 and the paragraph vertically aligned with the image in the right column, so that the title and the paragraph are aligned with the center of the image. Do you know how to achieve that?



Also do you know why the jumbotron is not aligned with the navbar? The "Title" is more to the left than the navbar image at left and also the image in the jumbotron is more to the right than the last item of the navbar. Do you know why?



I have a demo of the issues here:



https://jsfiddle.net/upmanct4/



HTML:



<div class="container">
<nav class="navbar navbar-expand-lg navbar-light py-4">
<a class="navbar-brand">
<img src="https://via.placeholder.com/110" width="110" height="25">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
</div>

<div class="jumbotron jumbotron-fluid">
<div class="container">
<div class="row">
<div class="col-7">
<h1 class="display-5 font-weight-bold text-dark">Title</h1>
<p class="lead text-light">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias earum tempore, eveniet quis quae quo placeat ullam, maxime harum at corrupti, vel, cumque error pariatur veritatis doloribus libero quibusdam hic.</p>
</div>

<div class="col-5">
<img src="https://via.placeholder.com/490" width="490" height="300">
</div>
</div>
</div>
</div>









share|improve this question



























    0














    I have this code for a bootstrap jumbotron, however I would like to have the column at left with the h1 and the paragraph vertically aligned with the image in the right column, so that the title and the paragraph are aligned with the center of the image. Do you know how to achieve that?



    Also do you know why the jumbotron is not aligned with the navbar? The "Title" is more to the left than the navbar image at left and also the image in the jumbotron is more to the right than the last item of the navbar. Do you know why?



    I have a demo of the issues here:



    https://jsfiddle.net/upmanct4/



    HTML:



    <div class="container">
    <nav class="navbar navbar-expand-lg navbar-light py-4">
    <a class="navbar-brand">
    <img src="https://via.placeholder.com/110" width="110" height="25">
    </a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
    aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav ml-auto">
    <li class="nav-item active">
    <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
    </li>
    <li class="nav-item">
    <a class="nav-link" href="#">Link</a>
    </li>
    <li class="nav-item dropdown">
    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
    data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropdown
    </a>
    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
    <a class="dropdown-item" href="#">Action</a>
    <a class="dropdown-item" href="#">Another action</a>
    <div class="dropdown-divider"></div>
    <a class="dropdown-item" href="#">Something else here</a>
    </div>
    </li>
    <li class="nav-item">
    <a class="nav-link disabled" href="#">Disabled</a>
    </li>
    </ul>
    </div>
    </nav>
    </div>

    <div class="jumbotron jumbotron-fluid">
    <div class="container">
    <div class="row">
    <div class="col-7">
    <h1 class="display-5 font-weight-bold text-dark">Title</h1>
    <p class="lead text-light">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias earum tempore, eveniet quis quae quo placeat ullam, maxime harum at corrupti, vel, cumque error pariatur veritatis doloribus libero quibusdam hic.</p>
    </div>

    <div class="col-5">
    <img src="https://via.placeholder.com/490" width="490" height="300">
    </div>
    </div>
    </div>
    </div>









    share|improve this question

























      0












      0








      0







      I have this code for a bootstrap jumbotron, however I would like to have the column at left with the h1 and the paragraph vertically aligned with the image in the right column, so that the title and the paragraph are aligned with the center of the image. Do you know how to achieve that?



      Also do you know why the jumbotron is not aligned with the navbar? The "Title" is more to the left than the navbar image at left and also the image in the jumbotron is more to the right than the last item of the navbar. Do you know why?



      I have a demo of the issues here:



      https://jsfiddle.net/upmanct4/



      HTML:



      <div class="container">
      <nav class="navbar navbar-expand-lg navbar-light py-4">
      <a class="navbar-brand">
      <img src="https://via.placeholder.com/110" width="110" height="25">
      </a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
      aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto">
      <li class="nav-item active">
      <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item dropdown">
      <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
      data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      Dropdown
      </a>
      <div class="dropdown-menu" aria-labelledby="navbarDropdown">
      <a class="dropdown-item" href="#">Action</a>
      <a class="dropdown-item" href="#">Another action</a>
      <div class="dropdown-divider"></div>
      <a class="dropdown-item" href="#">Something else here</a>
      </div>
      </li>
      <li class="nav-item">
      <a class="nav-link disabled" href="#">Disabled</a>
      </li>
      </ul>
      </div>
      </nav>
      </div>

      <div class="jumbotron jumbotron-fluid">
      <div class="container">
      <div class="row">
      <div class="col-7">
      <h1 class="display-5 font-weight-bold text-dark">Title</h1>
      <p class="lead text-light">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias earum tempore, eveniet quis quae quo placeat ullam, maxime harum at corrupti, vel, cumque error pariatur veritatis doloribus libero quibusdam hic.</p>
      </div>

      <div class="col-5">
      <img src="https://via.placeholder.com/490" width="490" height="300">
      </div>
      </div>
      </div>
      </div>









      share|improve this question













      I have this code for a bootstrap jumbotron, however I would like to have the column at left with the h1 and the paragraph vertically aligned with the image in the right column, so that the title and the paragraph are aligned with the center of the image. Do you know how to achieve that?



      Also do you know why the jumbotron is not aligned with the navbar? The "Title" is more to the left than the navbar image at left and also the image in the jumbotron is more to the right than the last item of the navbar. Do you know why?



      I have a demo of the issues here:



      https://jsfiddle.net/upmanct4/



      HTML:



      <div class="container">
      <nav class="navbar navbar-expand-lg navbar-light py-4">
      <a class="navbar-brand">
      <img src="https://via.placeholder.com/110" width="110" height="25">
      </a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
      aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto">
      <li class="nav-item active">
      <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item dropdown">
      <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
      data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      Dropdown
      </a>
      <div class="dropdown-menu" aria-labelledby="navbarDropdown">
      <a class="dropdown-item" href="#">Action</a>
      <a class="dropdown-item" href="#">Another action</a>
      <div class="dropdown-divider"></div>
      <a class="dropdown-item" href="#">Something else here</a>
      </div>
      </li>
      <li class="nav-item">
      <a class="nav-link disabled" href="#">Disabled</a>
      </li>
      </ul>
      </div>
      </nav>
      </div>

      <div class="jumbotron jumbotron-fluid">
      <div class="container">
      <div class="row">
      <div class="col-7">
      <h1 class="display-5 font-weight-bold text-dark">Title</h1>
      <p class="lead text-light">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias earum tempore, eveniet quis quae quo placeat ullam, maxime harum at corrupti, vel, cumque error pariatur veritatis doloribus libero quibusdam hic.</p>
      </div>

      <div class="col-5">
      <img src="https://via.placeholder.com/490" width="490" height="300">
      </div>
      </div>
      </div>
      </div>






      css twitter-bootstrap






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 '18 at 19:16









      user10676579

      685




      685
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Use .align-items-center on .row
          This will vertically align both .col-7 and .col-5 within the .row



          <div class="row align-items-center">
          <div class="col-7">
          <h1 class="display-5 font-weight-bold text-dark">Title</h1>
          <p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias earum tempore, eveniet quis quae quo placeat ullam, maxime harum at corrupti, vel, cumque error pariatur veritatis doloribus libero quibusdam hic.</p>
          </div>

          <div class="col-5">
          <img src="https://via.placeholder.com/490" width="490" height="300">
          </div>
          </div>


          Alternately you can use .align-self-center on the .col-7
          This will vertically align only .col-7
          If .col-7 happens to have a greater height than the .col-5, .col-5 will remain at the top of the .row since .col-5 is not vertically aligned within the .row



          <div class="row">
          <div class="col-7 align-self-center">
          <h1 class="display-5 font-weight-bold text-dark">Title</h1>
          <p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias earum tempore, eveniet quis quae quo placeat ullam, maxime harum at corrupti, vel, cumque error pariatur veritatis doloribus libero quibusdam hic.</p>
          </div>

          <div class="col-5">
          <img src="https://via.placeholder.com/490" width="490" height="300">
          </div>
          </div>





          share|improve this answer





















          • Thanks, do you know also why the jumbotron is not horizontally aligned with the navbar? The "Title" is more to the left than the navbar image at left and also the image in the jumbotron is more to the right than the last item of the navbar.
            – user10676579
            Nov 20 '18 at 19:30












          • It seems that is necessary to add "px-0" to the navbar.
            – user10676579
            Nov 20 '18 at 19:34











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400024%2fhow-to-have-the-two-columns-vertically-aligned%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Use .align-items-center on .row
          This will vertically align both .col-7 and .col-5 within the .row



          <div class="row align-items-center">
          <div class="col-7">
          <h1 class="display-5 font-weight-bold text-dark">Title</h1>
          <p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias earum tempore, eveniet quis quae quo placeat ullam, maxime harum at corrupti, vel, cumque error pariatur veritatis doloribus libero quibusdam hic.</p>
          </div>

          <div class="col-5">
          <img src="https://via.placeholder.com/490" width="490" height="300">
          </div>
          </div>


          Alternately you can use .align-self-center on the .col-7
          This will vertically align only .col-7
          If .col-7 happens to have a greater height than the .col-5, .col-5 will remain at the top of the .row since .col-5 is not vertically aligned within the .row



          <div class="row">
          <div class="col-7 align-self-center">
          <h1 class="display-5 font-weight-bold text-dark">Title</h1>
          <p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias earum tempore, eveniet quis quae quo placeat ullam, maxime harum at corrupti, vel, cumque error pariatur veritatis doloribus libero quibusdam hic.</p>
          </div>

          <div class="col-5">
          <img src="https://via.placeholder.com/490" width="490" height="300">
          </div>
          </div>





          share|improve this answer





















          • Thanks, do you know also why the jumbotron is not horizontally aligned with the navbar? The "Title" is more to the left than the navbar image at left and also the image in the jumbotron is more to the right than the last item of the navbar.
            – user10676579
            Nov 20 '18 at 19:30












          • It seems that is necessary to add "px-0" to the navbar.
            – user10676579
            Nov 20 '18 at 19:34
















          0














          Use .align-items-center on .row
          This will vertically align both .col-7 and .col-5 within the .row



          <div class="row align-items-center">
          <div class="col-7">
          <h1 class="display-5 font-weight-bold text-dark">Title</h1>
          <p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias earum tempore, eveniet quis quae quo placeat ullam, maxime harum at corrupti, vel, cumque error pariatur veritatis doloribus libero quibusdam hic.</p>
          </div>

          <div class="col-5">
          <img src="https://via.placeholder.com/490" width="490" height="300">
          </div>
          </div>


          Alternately you can use .align-self-center on the .col-7
          This will vertically align only .col-7
          If .col-7 happens to have a greater height than the .col-5, .col-5 will remain at the top of the .row since .col-5 is not vertically aligned within the .row



          <div class="row">
          <div class="col-7 align-self-center">
          <h1 class="display-5 font-weight-bold text-dark">Title</h1>
          <p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias earum tempore, eveniet quis quae quo placeat ullam, maxime harum at corrupti, vel, cumque error pariatur veritatis doloribus libero quibusdam hic.</p>
          </div>

          <div class="col-5">
          <img src="https://via.placeholder.com/490" width="490" height="300">
          </div>
          </div>





          share|improve this answer





















          • Thanks, do you know also why the jumbotron is not horizontally aligned with the navbar? The "Title" is more to the left than the navbar image at left and also the image in the jumbotron is more to the right than the last item of the navbar.
            – user10676579
            Nov 20 '18 at 19:30












          • It seems that is necessary to add "px-0" to the navbar.
            – user10676579
            Nov 20 '18 at 19:34














          0












          0








          0






          Use .align-items-center on .row
          This will vertically align both .col-7 and .col-5 within the .row



          <div class="row align-items-center">
          <div class="col-7">
          <h1 class="display-5 font-weight-bold text-dark">Title</h1>
          <p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias earum tempore, eveniet quis quae quo placeat ullam, maxime harum at corrupti, vel, cumque error pariatur veritatis doloribus libero quibusdam hic.</p>
          </div>

          <div class="col-5">
          <img src="https://via.placeholder.com/490" width="490" height="300">
          </div>
          </div>


          Alternately you can use .align-self-center on the .col-7
          This will vertically align only .col-7
          If .col-7 happens to have a greater height than the .col-5, .col-5 will remain at the top of the .row since .col-5 is not vertically aligned within the .row



          <div class="row">
          <div class="col-7 align-self-center">
          <h1 class="display-5 font-weight-bold text-dark">Title</h1>
          <p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias earum tempore, eveniet quis quae quo placeat ullam, maxime harum at corrupti, vel, cumque error pariatur veritatis doloribus libero quibusdam hic.</p>
          </div>

          <div class="col-5">
          <img src="https://via.placeholder.com/490" width="490" height="300">
          </div>
          </div>





          share|improve this answer












          Use .align-items-center on .row
          This will vertically align both .col-7 and .col-5 within the .row



          <div class="row align-items-center">
          <div class="col-7">
          <h1 class="display-5 font-weight-bold text-dark">Title</h1>
          <p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias earum tempore, eveniet quis quae quo placeat ullam, maxime harum at corrupti, vel, cumque error pariatur veritatis doloribus libero quibusdam hic.</p>
          </div>

          <div class="col-5">
          <img src="https://via.placeholder.com/490" width="490" height="300">
          </div>
          </div>


          Alternately you can use .align-self-center on the .col-7
          This will vertically align only .col-7
          If .col-7 happens to have a greater height than the .col-5, .col-5 will remain at the top of the .row since .col-5 is not vertically aligned within the .row



          <div class="row">
          <div class="col-7 align-self-center">
          <h1 class="display-5 font-weight-bold text-dark">Title</h1>
          <p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias earum tempore, eveniet quis quae quo placeat ullam, maxime harum at corrupti, vel, cumque error pariatur veritatis doloribus libero quibusdam hic.</p>
          </div>

          <div class="col-5">
          <img src="https://via.placeholder.com/490" width="490" height="300">
          </div>
          </div>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 '18 at 19:26









          user1521516

          5317




          5317












          • Thanks, do you know also why the jumbotron is not horizontally aligned with the navbar? The "Title" is more to the left than the navbar image at left and also the image in the jumbotron is more to the right than the last item of the navbar.
            – user10676579
            Nov 20 '18 at 19:30












          • It seems that is necessary to add "px-0" to the navbar.
            – user10676579
            Nov 20 '18 at 19:34


















          • Thanks, do you know also why the jumbotron is not horizontally aligned with the navbar? The "Title" is more to the left than the navbar image at left and also the image in the jumbotron is more to the right than the last item of the navbar.
            – user10676579
            Nov 20 '18 at 19:30












          • It seems that is necessary to add "px-0" to the navbar.
            – user10676579
            Nov 20 '18 at 19:34
















          Thanks, do you know also why the jumbotron is not horizontally aligned with the navbar? The "Title" is more to the left than the navbar image at left and also the image in the jumbotron is more to the right than the last item of the navbar.
          – user10676579
          Nov 20 '18 at 19:30






          Thanks, do you know also why the jumbotron is not horizontally aligned with the navbar? The "Title" is more to the left than the navbar image at left and also the image in the jumbotron is more to the right than the last item of the navbar.
          – user10676579
          Nov 20 '18 at 19:30














          It seems that is necessary to add "px-0" to the navbar.
          – user10676579
          Nov 20 '18 at 19:34




          It seems that is necessary to add "px-0" to the navbar.
          – user10676579
          Nov 20 '18 at 19:34


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400024%2fhow-to-have-the-two-columns-vertically-aligned%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Create new schema in PostgreSQL using DBeaver

          Deepest pit of an array with Javascript: test on Codility

          Costa Masnaga