Div being visually overtaken by background image

I am struggling to make the image declared in bg fit into the container-fluid without overflowing. You can check out the live example at .

The main objective is to position the text on top of the image so that I can apply opacity and blur effects to the image without affecting the text.

I have attempted to use overflow:hidden;, but it seems to be ignored.

Furthermore, even when I replace the background images with a background-color, the issue persists.

<div class="container-fluid">
   <div class="bg"></div>
   <div class="row hero_header">
      <h1>test</h1>
    </div>
</div>

CSS

.bg /*this is the background image*/
  {
      position: absolute;
      z-index: -1;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      background: url("/images/record_wall_orig_two.jpg") 0px 0px;
      background-size:cover;
      height:100vh;
      background-color: black;
      -webkit-filter:  blur(8px); / Chrome, Safari, Opera /
      filter:  blur(8px);
  }

Answer №1

To effectively position the ".bg" element, it is crucial to specify a relative position in relation to its parent and set overflow to hidden. Please try this method and inform me of the outcome.

Answer №2

Take a look at the code snippet below for reference and inspiration.

HTML:

<div class="jumbotron">
      <div class="container>
        <p>This template showcases a simple marketing or informational website design. It features a prominent jumbotron and three supporting content sections. Use this as a foundation to build something unique.</p>
        <p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more »</a></p>
      </div>
    </div>

CSS:

.jumbotron {
  background: url("https://static.pexels.com/photos/28209/pexels-photo-28209-large.jpg") center;
  background-color: black;


}

p {
   color: white; 
   font: bold 24px/45px Helvetica, Sans-Serif; 
   letter-spacing: -1px;  
   background: rgb(0, 0, 0); /* fallback color */
   background: rgba(0, 0, 0, 0.7);
   padding: 10px; 
}

View the working fiddle.

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

CSS: Troubles with Element Widths

I'm dealing with a list item that contains an image, like so: <ul> <li> <img></img> </li> </ul> The image is not filling the entire width of the list item. Is there a way to make the list item shr ...

Tips for customizing the default styles of PrimeNG's <p-accordion> tag

Hello, I have encountered an issue with my html code snippet. I am attempting to create a tab with a label-header named "Users", but the accordion tag consistently displays it as underlined. <div class="ui-g"> <p-accordion id="tabsHeader"> ...

Deselect an HTML checkbox using a corresponding label's "for" attribute

Below is the html code I am using to display a checkbox with an image: <div class="testClass"> <input id="111" name="compare_checkbox" type="checkbox" /> <label for="111"> <i class="icon" aria-hidden="true"&g ...

Tips for layering one div on top of another div

I'm looking for guidance on how to position my button divs over my Trapezoids in an overlay fashion. Currently, I have set up an array to store the colors and utilizing the map function to match each button with its corresponding color type. When a ...

Creating a clean layout with Bootstrap 4: Utilizing white space in the navbar and various sections

After encountering several issues on my website, I attempted to resolve them. While some problems were successfully solved, others remained unsolved. Frustrated by multiple failures, I decided to seek help by posting this question. Problem 1: A blank spac ...

Display the widget beyond the boundaries of the sidebar

Currently, I am using my own custom theme called Total. I want to display the Sidebar Login plugin's widget in the header section of my website. I attempted to do this with the following code: <div class="login"><?php the_widget('sideba ...

Difficulty with the responsiveness of a website due to issues with the bootstrap grid system

I've been working with a Bootstrap grid that you can find at . While it works perfectly on large desktop screens, everything is a bit messy on mobile devices. The "NEW" text specifically is not visible on mobile and doesn't seem to be responsive. ...

Sticky positioning causes elements to stick to the window as the

https://i.stack.imgur.com/nv3vU.png I am facing an issue with a position sticky block that can vary in height relative to the window size. Sometimes, the block is taller than the viewport, making it impossible to scroll to see all the content. Is there a ...

I am currently working on a project using ar.js

I came across a glitch code that triggers a video when scanning the marker. However, I encountered an issue where it only works on desktop. On Chrome for Android, the video does not appear, only the sound can be heard. I need assistance as my coding knowle ...

The color of a Three.js plane appears more intense with the addition of lights

import * as THREE from 'three'; import {OrbitControls} from 'three/examples/jsm/controls/OrbitControls.js'; import * as dat from 'dat.gui'; const renderer = new THREE.WebGL1Renderer(); renderer.shadowMap.enabled = true re ...

HTML list style with varying images at the same level in a ul tag

I am working on an Application that generates output with li tags. I am trying to find a way to apply different list-style-image for each li tag of the same level within the ul, while keeping the HTML code as simple as possible. Each li with a class of gre ...

CSS switch status toggle

Here's my code for a toggle switch from . I'm trying to change the label before the switch/checkbox to display "checked" or "not checked" based on the toggle state. When I click on the label, it changes the switch but not the text. JavaScript: ...

Utilizing Express to send a GET request to a search bar

I recently added a search bar to the homepage of my website. Users can input a string into the search bar, which will then be sent as a GET request. I am attempting to retrieve all data from my MongoDB where the input string is found within the name field. ...

Adjust the transparency level of the image's mapped area

I need help with changing the opacity of a specific area on an image map when clicked. The image has three areas, but I only want to target and change the opacity of the test2 area regardless of which area is clicked. Since my knowledge of jQuery syntax is ...

Deciphering the elements in the periodic table using PHP and HTML

Recently, I encountered a problem that got me thinking. I was given the task of posting people's bios online (as discussed in another question) and I chose to use XML to create elements for each section of the bio. However, when some bios contained ...

The table's value remains unchanged despite updating the data in $localStorage using AngularJS

In my AngularJS project, I have implemented two components. The first component, usersList, consists of a table: <table> <tbody> <tr ng-repeat="..."><!--Contains code to repeat the entries in usersList localstorage object-->& ...

Styling elements with CSS can sometimes lead to unexpected behavior in Safari on iOS devices, especially

Ever since the release of iOS 14, I've noticed that content within a div element with an 'overflow-y: scroll' property no longer functions properly on Safari. Does anyone happen to have a solution for this? (Or maybe my code just needs some ...

Trouble with recognizing nested functions when calling them in an onClick event

Encountering a `not defined` error on the console when attempting to call nested functions with an `onClick` event in an HTML page. After searching for solutions without success, I suspect it may be a scope or closure issue, but I am unsure of how to addre ...

Unable to access Bootstrap dropdown menu after initial ajax form submission

I am encountering an issue with a dropdown menu on my webpage, specifically within the manager.php file. Please excuse any formatting discrepancies as I am using Bootstrap: <!-- Bootstrap --> <script type="text/javascript" src="https://netdna ...

What's the issue with my ExpressJS req.query not functioning as expected?

My NodeJS repl setup includes an input, button, and h1 element. The goal is to update the HTML inside the h1 element with the value of the input upon button click. Here's a glimpse of my code: index.js: const Database = require("@replit/database ...