The background image causes the scrollbar to vanish

As a beginner, I am in the process of creating a web page that features a consistent background image. However, I have encountered an issue where the scroll bar does not appear on a specific page called "family details" due to the background image.

I attempted to address this problem by using an image tag instead of a background image, but this caused the content to display below the image rather than over it.

Solution Attempts:

<div class="background-image">
    <router-outlet></router-outlet>
</div>

This solution involved setting the background image through CSS:

.background-image {
    background-image: url('assets/icf.jpg');
    background-position: center top;
    background-size: 100% auto;
}

Alternatively, here is how I attempted to implement the image tag:

<img src="assets/icf.jpg" alt="/">
<router-outlet></router-outlet>

Answer №1

If you want to ensure your image remains behind other content, consider using the z-index property to assign a lower value to the img tag compared to the rest of the elements.

<img src="assets/icf.jpg" alt="/" style="z-index: 0;">
<div class ="all-your-other-stuff" style="z-index: 1;"></>

.img{
background-image: url("https://dummyimage.com/200x200");
z-index: 0;
height: 200px;
width: 200px;
}

.content{

z-index: 1;
}
<div class="img">
<div class="content">TEXT ABOVE IMAGE</div>

Answer №2

body {
  background-image: url('https://dummyimage.com/200x200');
  height: 100%;
  width: 100%;
}
<html>
<body>
<p>Adding some test data here</p>
</body>
</html>

Experiment by setting an image as the background for the Body tag with the use of the background-image property in CSS along with the repeat-x and repeat-y properties.

This will ensure that the image remains at the background consistently.

Answer №3

To incorporate the image into the index.html file, ensure that the container div for your Angular code has a higher z-index. See the relevant snippet from the index.html below:

 <div class='bkgClass'>
    <div class='insideClass'>
        <my-app>loading</my-app>
    </div>
</div>

<style>
    .bkgClass {
        height: 100vh;
        width: 100vw;
        background: url("https://beta.akberiqbal.com/JumboMobT.JPG");
    }

    .insideClass {
        z-index: 1;
    }
</style>

No modifications are required in your app.component or any other components;

You can view a demo on StackBlitz here

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

Navigating within the tab feature in Ionic: A Comprehensive Guide

My journey with Ionic has just begun, and I have some familiarity with Angular. In my tabs template, the Activity tab displays 3 tab-buttons on the page, as shown in the image below: https://i.stack.imgur.com/YlMLb.png When the user clicks on: About bu ...

Storing a multi-dimensional array in PHP efficiently

My PHP data consists of user limits: $userLimit = array( "default" => array( "playlistLimit" => 1, "mediaLimit" => 2, ), "editor" => array( "playlist ...

What is the best way to add a multiselect option in Django to display detailed information for each selected item

Experience the Description Image I am looking to develop a mini demonstration similar to the image provided. When I click on an item in the left column to select a country, I want the right column to dynamically display all the cities of the chosen countr ...

The overlay on the mobile device is too large for the screen

I've designed a basic div overlay using the CSS code below: position:absolute; top:0; left:0; display:none; cursor:default; z-index:101; width:100%; height:100%; To show the overlay, jQuery is utilized. Everything works perfectly on desktop browsers ...

Does the AngularJS inject function operate synchronously?

Does the AngularJS inject method work synchronously? Here is an example: inject(function(_$compile_, _$rootScope_) { $compile = _$compile_; rootScope = _$rootScope_.$new(); }); ...

The Kenburn zoom image effect fails to function

I want to implement a zoom effect on an image using the Ken Burns effect when it is clicked. However, the code I have written does not seem to be working as expected. Here is the code snippet: $(document).ready(function () { $('.kenburns').on( ...

Creating an ImmutableJS Record with custom types: A step-by-step guide

Is there a way to make ImmutableJS Records throw runtime exceptions if fields are missing instead of needing default values? ...

Terminate the rethinkdb data stream

Currently delving into the world of RethinkDB and am eager to utilize the changes() method to fetch a changefeed. While I've figured out how to initiate them, the documentation doesn't quite explain how to halt a changefeed. Is it sufficient to ...

Prevent a specific image from being impacted by CSS styling

I've implemented the following CSS on my website for image opacity: img { opacity:0.4; filter:alpha(opacity=40); } img:hover { opacity:1; filter:alpha(opacity=100); } Now, I am looking to exclude certain images from being affected by this ...

The CSS styles for a:link, a:active, and a:visited do not seem to work with

My page contains the following CSS rule: a:link,a:active,a:visited{text-decoration:none;} I have encountered an issue where this rule is not working as expected. To apply the rule within a div with the id="test", I had to modify the rule like this: #tes ...

What could be causing the span class data to not be retrieved by the getText method

Looking to retrieve the value of a span class called 'spacer-right big project-card-measure-secondary-info' <span class="spacer-right big project-card-measure-secondary-info">1</span> snippet of code: browser.waitForEl ...

Is it possible to dynamically alter the href attribute of a hyperlink within a Twig template in Symfony 2?

Developing a menu for my website has been occupying my time lately, sparking numerous inquiries about its functionality. Essentially, I aim to create a menu with a select option containing all my projects. By clicking on either the modify or delete button, ...

Tips on dividing a CSS file into separate lines for improved readability

I came across a dilemma while working with a 3rd party CSS file that is all one long line. Both the Sublime 2 text editor and Eclipse CSS editor were unable to split the file into easily readable style blocks. Can anyone recommend tools or methods for bre ...

Exploring the loading of stateful data in ReactJS and implementing optimizations

Exploring the world of ReactJS in conjunction with Django Rest Framework (DRF) def MyModel(model): ... status = ChoiceField(['new', 'in progress', 'completed'...]) In my application, I have dedicated sections for eac ...

Exploring the transition from JavaScript to jQuery

Currently, I have set up an ajax request in combination with JavaScript to fetch data from an external file. The code looks like this: const ajaxRequest = new XMLHttpRequest(); const handleResponse = function() { if (ajaxRequest.readyState === 4) { ...

Leverage closures within Underscore.js templates for enhanced functionality

Is there any benefit to utilizing a closure in an underscore template for purposes such as keeping track of counters? Here's a simple example: <% (function( models ){ var length = models.length-1, section = ""; _.each( models, functi ...

Is there a way to customize the animation for a button in material UI?

Trying to implement material UI in React and looking for a button that does not have the standard wave animation effect upon clicking, which you can see demonstrated here. Instead, I am searching for an animation that instantly fills the entire button wit ...

tips for sending types as properties in a versatile component

I am facing a challenge with passing types as props to a reusable component. I have a component where I pass rows and headings as props, but I need to find a way to pass types as props as well. Below is the code for my reusable component: import { TableCe ...

Top location for Cordova/Phonegap events in AngularJS

Currently, I am working on an AngularJS Cordova app and so far everything is progressing smoothly. My next objective is to integrate Cordova plugins into the application, specifically the Cordova Connect plugin, which will allow me to monitor network conne ...

Hover Effect with CSS Selector - JavaScript or jQuery Implementation

I have a similar code snippet: <article class="leading-0"> <h2> <a href="link">link title</a> </h2> <ul class="actions"> <li class="print-icon"> <a ...><img...>& ...