Balanced margins above and below the text

Could you help me adjust the text spacing to be consistent on both large and small screens, like in the examples below: https://i.sstatic.net/ideGH.jpg

https://i.sstatic.net/wwvHE.jpg

Note: The spacing should be equal at the top and bottom on all screen sizes to ensure responsiveness across various devices.

I'm currently using Bootstrap 4. Here's the HTML and CSS code that requires modification:

<!DOCTYPE html>
<html>
   <head>
      <title>Background Top</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1" >
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" />
      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
   </head>
   <style type="text/css">
      body{
        margin-top: 53px;
      }
      .navbar-custom { 
        background-color: #484848;
      }
      ul.ml-auto > li > a > span{
        font: 15px Roboto,sans-serif;
        font-weight: 500;
        position: relative;
        display: inline-block;
        color: #FFFFFF80;
        overflow: hidden;
        padding-bottom: 5px;
      }
      .nav-link {
        padding: .5rem 1rem 0; /*top right bottom*/
      }
      .jumbotron {
        background-image: url("background1.jpg");
        text-align: center;
        height:523px;
        background-size: cover;
        margin:0 !important;
        display: flex;
        justify-content: center;
        flex-direction: column;
      }
      .mainText {
        width: 100%;
        font-family: Verdana,sans-serif;
        font-size: 120px !important;
        margin-top: 35px; 
        color: black;
        margin: 0 0 5rem 0;
        animation-duration: 2s;
        animation-iteration-count:infinite;
        animation-delay: 1s;
      }
      .subText {
        font-size: 20px;
        font-family: Georgia,serif;
        font-style:italic;
        line-height: 1.6;
        color: black;
        animation-duration:2s;
        animation-iteration-count:infinite;
        animation-delay:1s;
      }
      @media screen and (max-width: 768px) {
        .mainText {
          margin-bottom: 0;
        }
        .subText {
          display: none;
        }
      }
   </style>
   <body>
      <nav class="navbar navbar-custom navbar-expand-lg navbar-dark fixed-top" id="mainNav">
         <div class="container">
            <a  style="font: 20px Arial,sans-serif" class="navbar-brand js-scroll-trigger" href="#">HOME</a>
            <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarResponsive">
               <ul class="navbar-nav ml-auto">
                  <li class="nav-item">
                     <a class="nav-link js-scroll-trigger" href="#LOREM"><span data-content="LOREM">LOREM</span></a>
                  </li>
                  <li class="nav-item">
                     <a class="nav-link js-scroll-trigger" href="#LOREM"><span data-content="LOREM">LOREM</span></a>
                  </li>
                  <li class="nav-item">
                     <a class="nav-link js-scroll-trigger" href="#LOREM"><span data-content="LOREM">LOREM</span></a>
                  </li>
                  <li class="nav-item">
                     <a class="nav-link js-scroll-trigger" href="#LOREM"><span data-content="LOREM">LOREM</span></a>
                  </li>
               </ul>
            </div>
         </div>
      </nav>
      <!-- //SECTION FOR PAGE TOP -->
      <section id="page-top">
         <div class="jumbotron">
            <p data-aos="zoom-out" data-aos-delay="500" class="lead mainText pulse green aos-init aos-animate" id="nametagneel">Carlos Qiano</p>
            <p data-aos="zoom-out" data-aos-delay="500" class="lead pulse lightGreen aos-init aos-animate d-md-block subText">Lorem Ipsum.<br>Lorem Ipsum.</p>
         </div>
      </section>
      <section id="about">
         <hr class="my-2">
         <br><br>
         <div class="container">
            <br>
            <h1 class="animated fadeIn delay-1s display-5">LOREM IPSUM</h1>
            <div class="row">
               <div class="animated fadeInUp delay-3s">
                  <div class="col px-5">
                     <p class="lead" style="font-family: Helvetica,sans-serif; text-align:justify;"><br>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
                  </div>
               </div>
            </div>
         </div>
         <br><br>
      </section>
   </body>
</html>

Thank you for your assistance!

Answer №1

Hello there! I have a cool tip for you regarding viewport height and width. By taking into account the screen size, you can achieve a more responsive design. Check out the snippet I prepared for your code:

@media (min-width: 576px)
.jumbotron {
    padding: 8vh 12vw;
}

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

jQuery plugin: Dynamic text rotator with color transitions

For more information about the jQuery plugin, visit this page: https://github.com/peachananr/simple-text-rotator Here's a link to my Fiddle: https://jsfiddle.net/jzhang172/8msf91wa/ Make sure to check out my external Fiddle link, as the code here ma ...

Navigating through stacks in React Native

My stack navigation was working perfectly at first, but now it seems to have stopped functioning :( npm install --save react-navigation npm install --save react-native-gesture-handler react-native link npm install When I run the commands above, I am enco ...

What is the best way to resize the mat-form-field mat-chip?

This is the result of my HTML coding https://i.sstatic.net/2KOvk.png I am trying to achieve uniform size for the mat-chip form field similar to the one above. I referenced this location for using chips. I am looking to reduce the size of the chip in the ...

Utilizing XPath with Selenium in VBA

In my search for a node based on text located within a child or grandchild node of its immediate sibling, I came across the following HTML structure: <div> <div class="searchedDivClass" id="DynamicId1"> </div> <div class=" ...

Interactive Ionic menu available on a designated page for enhanced user engagement

English is not my first language, so please bear with me. Here's the situation: I have a map section (using leaflet) on one page of my app, along with a menu for displaying data to the user. Currently, the menus are located in my app.component.html b ...

Website that substitutes every word on an external webpage

I'm looking to create a function similar to what's demonstrated on this site: which allows users to enter an address and view the page with all words replaced by a custom choice. Initially, I attempted this using iframes and jquery, but ran int ...

What is the best way to accomplish a smooth transition of background colors similar to this design

I was browsing different websites and stumbled upon this amazing background color transition that caught my attention. I really liked it and now I want to create something similar on my own website. Despite my best efforts, I haven't been able to achi ...

Modify a different tag within CSS

I am attempting to reduce the space between the words: "frihedskamp og fremtidsforelskelse" When I remove the CSS tag in line 149, the spacing returns to normal. To address this, I tried adding the following override on line 266: HTML <div class="col ...

Replace the surrounding tags of a specified text using Regular Expressions

I am working on a function that can search for specific text within a minified HTML string and then change the enclosing tag to h2. var htmlString = ` <h1>title</h1><p>Lorem ipsum dolor quas!</p><p>Lorem ipsum dolor</p> ...

How can the entire row in an ngTable be turned into a clickable hyperlink, allowing it to open in a new tab or window, using AngularJS?

Currently, I am using AngularJS in conjunction with ngtable. Whenever I create a table, my usual practice is to include ui-sref on the <tr> element as shown below: <tr ng-repeat="element in $data" ui-sref="app.some.details.info({id: element.id}) ...

Issue with connecting the 'Enter' key to the button - no success

My current setup involves using jQuery to link the Enter key to an HTML button through this code snippet: $("#console").keyup(function(event){ if(event.keyCode == 13) { $("#submit").click(); } }); HTML: <input autocomplete="off" type= ...

Interacting with the Dropdown feature on the page causes the body of the page to shift

I am encountering an issue with 2 dropdowns in Datatables used to filter content. The problem arises when a dropdown is positioned on the right side of the page, causing a shift to the left by approximately 10px. Conversely, if the dropdown is placed on th ...

Staging a div from a specific origin

On my HTML page, there is one div and a small round image. Initially, the div has a scale of 0 so it is not displayed. However, when I click on the small image, the div scales to 1 in the middle of the window. The position of my div is absolute. My issue n ...

Having trouble with getting the footer to display correctly on mobile when dealing with a scrollable section within another scrollable section in React and CSS

Looking for some assistance with a coding issue I've encountered. I have created a section on my website where I map components, which includes a vertical scroll. Outside of this section, there are other components such as a map, navbar, footer, etc. ...

The Signature Pad loses its focus

My HTML code is using JavaScript with Bootstrap and the Signature Pad. The issue I am facing is related to the Bootstrap Collapse feature. When I set the first panel as default, the Signature Pad does not allow me to sign. However, if I set the third panel ...

The functionality of "#button_1" remains unchanged despite using .click() or .hover() methods

Seems like I made a beginner's error - the #button_1 ID seems to be immune to the jQuery effects of click() or hover(). If someone could spare a moment to check out my JSFiddle, it would be incredibly helpful. It's likely something quite simple ...

Sliding in images with JQuery

I need help with animating the slide-in effect of 7 "card" images from the left to the center of the screen. I attempted to achieve this using the following code: function FetchCards() { $("#pack").css('margin-left', 0); $("#pack").css(& ...

JavaScript has the ability to manipulate the width of an element by using methods to both retrieve

I have a unique situation where I need to dynamically adjust the width of a ul list element based on the text content inside it. Specifically, I want the width of the ul list to be equal to the width of the first list item, which can change frequently. My ...

Clicking on the image will toggle the visibility of the parent container

I am currently working on a layout and am seeking assistance with a specific feature. The task at hand involves a container that has a set height of 288px and contains an image with a height of 576px. The requirement is that when a user clicks anywhere wit ...

Step-by-step guide on retrieving specific content from a PDF file using PHP

I have a task to store the name of a candidate and their ID in a MySQL table. I successfully extracted the text using a PDF parser. <?php // Include Composer autoloader if not already done. include 'vendor\autoload.php'; // Parse pdf f ...