Incorporating visuals on top of parallax effect using Bootstrap 4

Trying to master Bootstrap, I've hit a roadblock. I managed to set up a parallax image in bootstrap, but every time I try to add additional content like a card or another image, it all falls apart.

If I could just overlay a div on the parallax, that would solve my problem.

Here's the code with text as an example (I'm aiming to add an image or a row):

<div id="parallax-image">
  <section>
    <div class="parallax-one">
      <div class="text">
        <h2>Heading</h2>    
      </div>
    </div>
  </section>
</div>

CSS

#parallax-image .parallax-one{
  padding-top: 200px; 
  padding-bottom: 200px; 
  overflow: hidden;
  position: relative; 
  width: 100%; 
  background-image: url(img/paralax_1.jpg);
  background-attachment: fixed; 
  background-size: cover; 
  -moz-background-size: cover; 
  -webkit-background-size: cover; 
  background-repeat: no-repeat;
  background-position: top center;
}

Nothing fancy here except for a font family and alignment for .text. There's also a media query that adjusts paddings for smaller screens.

Edit I realized I can use negative margins based on the padding. By adding this to .text, I get a similar effect to what I want:

margin-bottom: -200px; margin-top: -140px

But I'm unsure if this approach might have any adverse effects.

Answer №1

Successfully integrating an image into your current code. Please advise if the displayed behavior does not meet your expectations?

#parallax-image .parallax-one{
overflow: hidden;
position: relative;
width: 100%;
background-image: url(http://theartmad.com/wp-content/uploads/2015/09/Best-Desktop-Background-1.jpg);
background-attachment: fixed;
-moz-background-size: cover;
-webkit-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
background-position: top center;
}
img {
  display: block;
  height: 50vh;
}
<div id="parallax-image">
<section>
  <div class="parallax-one">
    <div class="text">
      <h2>Heading</h2>    
    </div>
    <img src="http://cdn.apk-cloud.com/detail/screenshot/21TMCtcX5zkbnDViowtD6roqiEPWaitP46F8aDkvJxErPuirh_H6kCa-cJbZmCpsrQ=h300.png" alt="image" />
    <img src="http://cdn.apk-cloud.com/detail/screenshot/21TMCtcX5zkbnDViowtD6roqiEPWaitP46F8aDkvJxErPuirh_H6kCa-cJbZmCpsrQ=h300.png" alt="image" />
  </div>
</section>
</div>

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

JS will reach its stopping point at the specified style.zIndex

I am currently in the process of setting up button elements. I have two scripts that correspond to different types of buttons - one script runs a simple collapse menu, while the other executes a more complex collapse by shifting depths and sliding one div ...

Issues with Tags Functionality in Rails 5 Bootstrap JavaScript

I encountered some unusual issues while using Bootstrap 4 with the Rails 5 javascript tags. Initially, everything was working smoothly on this project and I hadn't made any modifications to the js files. However, suddenly, my collapsible navbar dropdo ...

What is the best way to prepopulate an HTML form field for email submission?

Looking for a way to prepopulate the subject field in an HTML form with To and From fields? I'd like to achieve this using JS or jQuery. I want the message to say "Hi, thanks for stopping by (followed by the rest of the message)..." just like LinkedI ...

jQuery will not carry out the initial trigger action more than once

I've successfully implemented a feature where clicking on one of the 3 divs causes the main container to slide half away by 600px and reveal a new container with additional options. However, I'm facing an issue where after closing the new content ...

Animate CSS every quarter of a minute

Is it possible to create an animation that runs infinitely every 15 seconds in the sequence 1, 2, 3, 4, 3, 2, 1 with different delays for each item using CSS? The animation delay seems to only work on the first iteration. Achieving this effect is easy wi ...

Concealing unnecessary borders on list elements using jQuery

Here is the code I am working with: http://jsfiddle.net/eLyJA/ I am looking to calculate and eliminate all border edges to achieve this visual effect: ...

Utilizing Ajax in ASP.NET to Execute a Controller's Void Method when Clicking a Button

I have a project for a .ASP MVC Web Application. My goal is to trigger a void method in the controller class when I click a button using AJAX. There is no need for any input or output data, just simply creating a PDF file and saving it locally. Currently, ...

The foundation grid system is not being implemented

How come my div is not affected by the foundation grid system: render: function(){ var {todos,showCompleted,searchText} = this.state; var filteredTodos = TodoAPI.filterTodos(todos,showCompleted,searchText); return ( <div> ...

When using Angular, automatically shift focus to the next input field by pressing the

I am faced with a challenge involving multiple editable inputs on my screen. Alongside these editable inputs, there are buttons and disabled inputs present. The current behavior is such that when I press Tab, the focus shifts to the HTML elements between ...

How can I stop labels from breaking onto separate lines in Bootstrap?

After developing a form using Bootstrap, I encountered an issue with the responsiveness on different devices. Specifically, when viewing the form on narrow screens, the labels for the inputs break into two lines due to lack of space. While this is expected ...

The swf file doesn't stretch to fit the window when the height is set to 100%

Struggling with creating a flash recorder controlled by JavaScript? Trying to get the flash to fill the browser window but disappearing when setting height or width to 100%? Where am I going wrong? <div id="flashrecorder"> <object wmode="trans ...

Error in conditional statement regarding the jQuery background color RGB value

I have thoroughly tested the remaining sections of my code and they are functioning correctly, however, it is not working within this particular section. This snippet of code seems to be where the errors or issues lie. if(bgc.css("background-color") == " ...

The checkbox is not properly aligned with the prompt due to the Bootstrap class

I am struggling with positioning a Bootstrap inline checkbox within the text prompt "Remember me on *this computer". The checkbox should appear right before the location marked by *. This issue arises from code borrowed from Chapter 9 of the Ruby on Rails ...

Cross-Origin Resource Sharing policy for cached images

In chrome 22 & safari 6. When attempting to load images from a CORS enabled S3 bucket for use in a canvas, some interesting observations were made. Here is the code snippet used: <!-- In the html --> <img src="http://s3....../bob.jpg" /> ...

The class for the Vuetify v-text-field component is not showing up

Struggling to include a class in v-text-field using Vuetify, only to find out that the class is missing when it renders in the DOM. <v-text-field label="Login" class="upper" name="login" prepend-icon="person" type="text" v-model="usuario"></v-tex ...

Graph Navigator - Time Series

Can anyone assist me with displaying dates on xAxes using Chart.js? I attempted to do it with 2 dates, but unfortunately nothing is being displayed. It seems like there may be an issue with the labels or date format that I used. <canvas id="graph"> ...

Flexbox margins (exceeding 100% total width)

Currently collaborating with @c4rlosls and we are facing 2 issues: https://i.sstatic.net/44WcI.jpg If the parent container with class container-fluid has a px-0, it extends beyond 100% width. Additionally, the elements with classes .cont2 a and .cont3 a do ...

Bootstrap grid collapses at the tiniest dimension

Here is a code snippet to create a responsive grid layout using Bootstrap: <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"> <div class="container"> <div class="row"> <label c ...

I am looking to dynamically assign CSS classes to elements in my HTML document. Additionally, my project utilizes Angular 5 and Bootstrap version 3.3.7

I am currently in the process of generating a table using data obtained from a JSON. Due to the potential for a large amount of data, I have implemented a loop to create all the rows within the table. My goal is to enable users to click on any specific row ...

Looking to refresh the dropdown menu utilized in HTML with Django

I created a Django web application and included a drop down field using the following code: <select id="countrynamew" name="countrynamew" value="{{countrynamew}}"> <option value="Abkhazia">Abkhazia</ ...