Padding in Twitter Bootstrap seems to be malfunctioning

I'm facing an issue with the positioning of my content relative to my navbar. Whenever I add padding-top: 60px;, it does position the content underneath the navbar, but it also pushes the navbar down. What I actually need is for the background to be at the top of the page behind the navbar. How can I resolve this? Right now, both the navbar and background are being pushed down along with the content, when I only want the content to be pushed down.

body {
    padding-top: 65px;
    margin: 0;
    width: 100%;
}

#header {
  background-color: grey;
  opacity: .7;
  width: 100%;
  height: 80px;
  position: fixed;
  z-index: 1000;
}

#logo a {
  font-size: 30px;
  font-weight: bold;
  color: rgb(255, 255, 255);
  font-family: 'DIN 1451 Std Engschrift';
  margin-top: 5px;
}

#slide1 {
  width: 100%;
  background: url('sunrise.png') 50% 0 no-repeat fixed;
  background-size: cover;
  color: #ffffff;
  height: 700px;
  margin: 0;
  padding: 40px 0 260px 0;
}

.content {
  margin: 0 auto;
  width: 1000px;
}
<div id="header">
        <div class="content">
    <nav id="nav" class="navbar navbar-expand-lg">
      <div id="logo">
        <a class="navbar-brand" href="#">Navbar Logo</a>
      </div>
          <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
          </button>
      <div id="logo">
        <div class="collapse navbar-collapse" id="navbarNav">
          <ul class="navbar-nav">
              <a class="nav-item nav-link" href="#slide3">How it Works</a>
              <a class="nav-item nav-link" href="#slide4">For Landlords</a>
              <a class="nav-item nav-link" href="#">F.A.Q</a>
              <a class="nav-item nav-link" href="#pricingslide">Pricing</a>
            </li>
          </ul>
        </div>
      </div>
    </nav>
  </div>
 </div>
    <body>
      <div id="slide1">
  <div class="content">
    <h1 id="headline">Use Your Rent To Buy A Home</h1>
    <p id="subtitle">Build a credit history, create a down payment,<br> all by just making rent payments thru LikeHome</p>
    <h3>Find out how soon you can become a homeowner?</h3>
    <%= render '_how_much_buying_form.html.erb' %>
  </div>
</div>
    </body>
    </html>

Answer №1

Does this task suit your needs?

body {
  margin: 0;
  width: 100%;
}

#slide1 {
  background: url('http://res.cloudinary.com/sayob/image/upload/v1526907328/483257_vwhhfw.jpg') 50% 0 no-repeat fixed;
  background-size: cover;
  color: #ffffff;
  height: 700px;
  padding: 40px;
  margin-top: 20px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">

<nav id="nav" class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
  <div id="logo">
    <a class="navbar-brand" href="#">Navbar Logo</a>
  </div>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
              <span class="navbar-toggler-icon"></span>
            </button>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item">
        <a class="nav-link" href="#slide3">How it Works</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#slide4">For Landlords</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">F.A.Q</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#pricingslide">Pricing</a>
      </li>
    </ul>
  </div>
</nav>

<div class="container-fluid" id="slide1">
  <h1 id="headline">Utilize Your Rent To Purchase A Home</h1>
  <p id="subtitle">Establish a credit history, form a down payment,<br> simply by fulfilling rent payments via LikeHome</p>
  <h3>Discover how soon you can own a home?</h3>
</div>

Answer №2

Begin by ensuring the HTML markups are accurate. Enclose all HTML content within a tag. Organize the elements within a body tag, then establish an additional div or section for the contents preceding the header. Apply padding to this div for improved layout.

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

Is there a way to eliminate the border surrounding every cell in a table?

I'm facing an issue with a table on a page with a gray background. The challenge is to remove the borders of the cells in the table. <table width="510"> <tbody> <tr> <td style="background-color: #fff;" colspan="2" width="510"> ...

When using an `if` statement in CSS to determine if the value of `left` is

Is there a way to trigger an event only when the object reaches a specific percentage of its left position? I am trying to achieve this using jQuery with the .css() method. Here is what I have so far: HTML: <div id="midDiv"><img ..../></di ...

Images that shrink in an inline block format

I'm having trouble making my in-line blocks shrink instead of wrapping. The layout of the images is currently like this: AAA BBB CCCCCC As the window narrows to the width of C, I want all the images to shrink together. Right now, what is happening ...

Swap the < symbol with &gt; and & with &amp; within a specific node or location in an XML document

Hello everyone, I have a XML file with a node named Section, where certain characters like & and < are treated as invalid. I need to replace < with &lt; and & with &amp; only within the Section Node. Currently, I am using the following Java ...

How to retrieve the content within a tag using Python regex without including the tag

I'm facing a dilemma: I've got some HTML code and I need to extract the content within tags. Instead of resorting to multiple substring operations, I'd like to employ regex for this task. However, I'm encountering difficulties when it c ...

The DOMDocument class in PHP allows you to manipulate a tree of nodes

Is there a way to transform HTML syntax into a node tree resembling the structure of an unordered list (<ul> element) using the DOMDocument class in PHP? $html = ' <div> <p> <a> </p> </d ...

html form-- assistance required in making new input area appear upon clicking radio button

Currently, I am in the process of creating a basic customer database using mysql and php. My goal is to have extra input fields appear for mailing address when users click on the radio button labeled "different mailing address". However, I'm unsure ab ...

What steps do I need to take to successfully get this JavaScript Timer working?

I'm currently working on developing a timer using JavaScript. However, I've encountered an issue where the timer does not stop once it reaches zero. I've attempted to use return and if statements without success. Is my approach correct, or i ...

Floating point expansion caused by the addition of padding

Currently working on a basic 2 column layout design for a website, but ran into a hiccup. Whenever I try adding padding to the left-floated column, it ends up expanding beyond the width that I have set. Unfortunately, I haven't been able to find a sol ...

Using jQuery's `replaceWith` method to swap out special HTML characters

I have a star displayed on my page using HTML entity code ☆ inside a div with the class "favorite": <div class="favorite">&#9734 </div> My goal is to replace this outlined star with a filled-in star when hovering over it. I attem ...

Unable to conceal adjacent element when z-index is set as 1

I encountered an issue where a modal is overlapping another element, and the close button of the underlying element has a z-index of 1. Despite creating a new modal with its own close button, the original close button remains visible on top. I attempted t ...

Incorporating a popover onto a button within an Angular-centric project

Having recently delved into Angular, I decided to create a basic page showcasing details of a legal case. To enhance the visual appeal, I incorporated Angular Material library for its attractive icons, which I intended to display alongside plaintiff and se ...

Observing DOM Events with Ember

I'm in the process of constructing a form element using Ember. Within this form, there is an Ember view/component for uploading a picture. Once the picture is uploaded, a thumbnail of the image is displayed. The form also includes a reset button and a ...

Anomalous reference in an external style sheet

Okay, so I'm admittedly quite new to programming, but I thought I had CSS referencing all figured out...turns out, not quite. I've tried including stylesheets both internally and externally, moving them around in different folders, you name it. B ...

I possess 9 captivating visuals that gracefully unveil their larger counterparts upon being clicked. Curiously, this enchanting feature seems to encounter a perplexing issue within the realm of web browsing

<style type="text/javascript" src="jquery-1.11.0.min.js"></style> <style type="text/javascript" src="myCode.js"></style> </body> //jquery is within my site directory on my desktop $(document).ready(function(){ //note: $("#ar ...

What is the best way to center CSS content such as boxes and text?

As a beginner in CSS tutorials, I am seeking guidance on how to center the entire content in the browser. Below is the CSS code that needs attention. Additionally, there is a screenshot of the current output included for reference. body { background:#E9 ...

Any tips on how to personalize the loading animation for single pages using CSS and GIFs?

presentLoading(message) { this.loading = this.loadingCtrl.create({ dismissOnPageChange: false, spinner:'hide', content:`<img class="load" src="assets/dual.gif" />`, }); this.loading.present(); } Hello there! I am working with the ...

What is the best way to update the color of a header in an HTML document

My HTML and CSS code is causing the h1 title to appear in blue instead of red. I am unsure why this is happening and how to fix it. Any help would be greatly appreciated. <!doctype html> <h1>les planètes du système solaire <h1> < ...

Transform your dictionary into an interactive HTML table that allows users to search through the results with ease

I have a university project where I need to exchange data via JSON using a Python script and a server, and then display it in a browser with an add and search function. The information being added includes student names, surnames, and ages. I must apologiz ...

Temporary pseudo-element that appears upon hovering

My animated arrows, implemented using pseudo elements, are experiencing an unusual behavior. When the link is hovered over, the arrows animate smoothly. However, upon leaving the link, a pseudo element briefly appears in the top left corner of the screen b ...