The resizing of the background image is contingent upon the size of the

I am facing an issue with my bootstrap carousel. One of the items only contains a background image without any content. I have set a height for it so that it is still visible even without content. However, when viewing on mobile devices, I can only see a portion of the image. How can I make the image resize according to screen size or in responsive web design view? I tried using position absolute on the specific item and making the parent div position relative, but the item disappears when position absolute is applied.

Here's the code snippet:

<div id="custom-banner-wrapper" style="position: relative;">
   <div id="custom-banner" class="carousel slide" data-ride="carousel">

     <div class="carousel-inner custom-banner-inner">

     <div id="custom-banner-fullwidth" class="item custom-banner-item active" 
     style='background-color: #2c1946;  background-image: url("./catalog/view/theme/broadwaytheme/images/banner-1.png");  background-repeat:no-repeat; background-position: top center; background-size: cover; position:absolute;'>
      <div class="container">
       <div class="row">
        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 custom-banner-caption">

        </div>
      </div>
    </div>
  </div>
</div>
<ol class="carousel-indicators" style="bottom:0px;">
  <li data-target="#custom-banner" data-slide-to="0" class="active"></li>
  <li data-target="#custom-banner" data-slide-to="1"></li>
  <li data-target="#custom-banner" data-slide-to="2"></li>
</ol> </div></div>

Answer №1

To solve your issue, try setting the
background-position to 100% 100%; and ensuring that max-height and max-width are both set to 100%


Implementing these changes should resolve the problem for you

Answer №2

To make the image fill the div completely, you can apply the css style property background-size:100% 100%. Alternatively, if you want the image to be contained within the div without stretching it, you can use background-size:contain. This will ensure that the image fits inside the div but may not cover the entire area.

Answer №3

To achieve the full coverage of your image and focus on the center part within your DIV, consider implementing the following patch:

.custom_style { background-size: cover; background-position:center center;}

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

Having trouble converting JSON into a JavaScript object

I am encountering an issue with my HTML box: <span>Select department</span><span> <select id="department" onchange="EnableSlaveSelectBox(this)" data-slaveelaments='{"a": 1, "b": "2& ...

Switching a Rails/Ajax form from create to update mode upon submission

While experimenting with a star ratings page, I encountered an issue where the form element remained in "Create" mode instead of updating to an "Update" method after submission. The rating form is ajaxified, but it lacks the functionality to dynamically sw ...

A guide to reordering table rows by drag-and-drop with JavaScript

Seeking assistance with swapping table rows using JQuery UI. Although successful in the swap, struggling to retrieve row numbers during the drag and drop event. Understanding the row number is essential for subsequent tasks. Any help would be greatly appre ...

Issues arising during the initialization of Tinymce

After setting the editor on the frontend, I encountered an issue with initializing tinymce. Here is my code: <head> <script src="//cdn.tinymce.com/4/tinymce.min.js"></script> </head> <body> <a class=pageedit>Edit< ...

Why is ng-bind-html not functioning within ng-repeat when ngSanitize is included in the module?

I'm a beginner with AngularJS and I'm trying to bind tags inside an ng-repeat loop, but I've tried using ng-bind-html and ng-bind-html-unsafe without success. The output is not displaying correctly. <script src="https://ajax.googleapis.c ...

Does the onChange event fire when the value is modified by the parent element?

let [number, set_number] = useState({x: 1}); <ChildComponent number={number} onUpdate={onUpdateFunction} </ChildComponent> set_number({x: 2}) After running set_number({x: 2}), will this action prompt the execution of onUpdateFunction refere ...

Just diving into JavaScript, what makes jQuery so powerful?

As a newcomer to javascript (although functional programming is no problem for me), I find myself questioning some of the design choices made by jQuery. Is it too late to make changes now, or are they simply too ingrained in the framework? For example, the ...

Combining 1 pixel borders to create a bolder border effect

How can I prevent the border from becoming 2 pixels when I have overlapping (touching) divs? I thought about putting borders on only 2 sides, but then one edge of the div would be without a border. By the way, I am utilizing jQuery Masonry. ...

What is the best way to add the SO-style <kbd> effect to my presentation made with HTML?

I'm currently utilizing reveal.js to construct an HTML-based presentation. My goal is to incorporate keyboard symbols like the ones found on SO and Github using the <kbd>SPACE</kbd> syntax, resulting in this glyph: SPACE. Despite attempti ...

What is the best way to conceal a sticky footer using another element?

I have a footer that remains fixed at the bottom of both long and short pages. Below is the CSS code for this footer: .footer{ position: absolute; bottom: 0; width: 100%; height: 100px; background-color: white; } My goal is to achieve a 'r ...

Bootstrap - the input group button is designed to align to the right side

Currently, I am in the process of constructing a navigation bar for a website that includes a search bar and a grouped button. Everything functions properly when viewed on a desktop, but as soon as I switch to mobile view and the collapsible menu is activa ...

Tips on containing the reach of a function in JavaScript/jQuery

I have a scenario where I have multiple .js files linked on the page, each containing functions with the same name. For example: first.js function DisplayContent(data,$target) // data is string { $target.html('<span>'+ data +'&l ...

Showcasing a dynamically created JSON document on a basic web page

Looking for a solution to display the contents of a result.json file generated by my Java tool on a simple website. I am aware that accessing local files directly with JavaScript is not possible, so seeking alternative methods that do not involve using a w ...

Troubleshooting issues with jQuery plugin functionality post-upgrade

My previous jQuery version was 1.4 or 1.8, but I upgraded to version 1.10.2 to access newer plugins. However, I encountered a problem - my jQuery code for editing attributes stopped working after the upgrade. Below is the code snippet: <script type="te ...

jquery-enhanced tabs with versatile functionality

HTML: <ul class="tabs"> <li><a href="#tab-one" class="current">Residential</a></li> <li><a href="#tab-two">Commercial</a></li> <li><a href="#tab-three">Agricultural</a></li> < ...

The HTML unit is unable to locate the form for unknown reasons. My suspicion is that it could be due to the presence of Angular

Struggling with using HTMLunit to login and upload a file. Successfully logged in but unable to locate the form, despite it being present on the HTML page. Here is the JAVA CODE snippet: public static void main(String[] args) { WebClient webClient = ...

Tips for displaying HTML content in an AJAX success alert message with ASP.NET MVC and jQuery

I have an action result that sends content in the following format: public ActionResult MyAction() { string mystring = //doing something return Content(mystring , "html"); } Client Side: $.ajax({ url: "/MyController ...

What is the best way to have the sidebar of a webpage slide out over the main body content that is being displayed?

Issue Summary I am experiencing an issue with the positioning of my sidebar, which is initially located 66% offscreen using -translate-x-2/3. The sidebar is meant to be pulled into view onmouseover, however, the main body content remains stuck in place. I ...

I am experiencing an issue where the CSS file in the wwwroot directory does not update when I make changes to the code in ASP.NET MVC

Here is a link to my CSS file: Click here for image description This is how the file looks when built (no changes): Click here for image description Occasionally, running "clean-solution" and "build-solution" fixes the issue, but it's not working no ...

Creating Email Designs with Multiple Layers for Outlook Versions 2007 and 2010

I hope you're all having a fabulous Aloha Friday! I have a question regarding HTML emails, specifically in relation to Outlook 2007 and 2010. Currently, I am working on a project that involves layering a couple of PNG images on top of each other, wel ...