Troubleshooting: Bootstrap CSS Bottom Class Issue

I'd like the text to sit right on top of the background image, with the message fixed in place at the bottom of the container. I've tried setting 'bottom: 0;' but it doesn't seem to work. The layout needs to be responsive, so I can't specify a fixed pixel amount for the position. Any idea what I might be missing?

.bg-img {
    z-index: 4;
    position: relative;
}
.bg-img img {
    width: 100%;
}
.message {
    position: absolute;
    z-index: 5;
    padding-top: 50px;
    padding-bottom: 50px;
    bottom: 0;
    background: rgba(232,218,193,0.03);
}

<section class="full-image-desc">
<div class="container-fluid message">
    <div class="row">
        <div class="col-xs-12 col-sm-offset-2 col-sm-8">
            <h1>Title</h1>
            <h2>Sub-Title</h2>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum elementum augue vitae magna ultricies, sit amet fermentum risus fringilla. Donec arcu eros, suscipit ut ornare id, tincidunt eget nisl. Pellentesque non massa quis nibh rutrum tempor a eget nisl. Vestibulum ut laoreet nulla, id posuere lectus. Nulla id est ligula. Mauris vitae ipsum sed metus eleifend interdum at ac tortor. Aliquam erat volutpat. Curabitur vel eleifend augue, eget consectetur purus. Sed imperdiet pulvinar urna at porta.</p>
        </div>
    </div>
</div>
<div class="bg-img">
   <img src="img/background-image.jpg" alt=""/>
</div>
</section>

Answer №1

If you want your website design to adapt to different devices, you'll need to include meta tags to instruct the browser on how to display the content on various platforms (Desktop, tablet, or phone). To overlay text on an image, both elements should be within the same div container.

<div class="col-xs-12 col-sm-offset-2 col-sm-8" background="img/background-image.jpg">
            <h1>Title</h1>
            <h2>Sub-Title</h2>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum elementum augue vitae magna ultricies, sit amet fermentum risus fringilla. Donec arcu eros, suscipit ut ornare id, tincidunt eget nisl. Pellentesque non massa quis nibh rutrum tempor a eget nisl. Vestibulum ut laoreet nulla, id posuere lectus. Nulla id est ligula. Mauris vitae ipsum sed metus eleifend interdum at ac tortor. Aliquam erat volutpat. Curabitur vel eleifend augue, eget consectetur purus. Sed imperdiet pulvinar urna at porta.</p>
        </div>

Alternatively, you can achieve this using CSS:

div {
    background-image: url("img/background-image.jpg");
}

I recommend using CSS for this purpose as it will simplify the process and make maintenance easier in the future.

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

Tips for downsizing a large image to fit into a smaller area

I am working on a page layout that features a small circular navigation element. However, I am facing an issue with fitting a large picture within the boundaries of this small circle without it overflowing and causing alignment problems. Does anyone have ...

Set boundaries for square dimensions and placement within the parent container

Struggling to confine a square within specific size constraints while keeping it neatly aligned within the parent container. Balancing these requirements has proven challenging. The layout consists of a main div with two columns on the left and a div occu ...

Arranging the form fields on top of an image

Check out the code I've been working on here. I'm facing an issue where the text disappears when I try to position it next to an image. Is it possibly going behind the image? Thank you for your assistance and time. ...

What is the best method to add a background image to a short div element?

For instance, here is some example HTML code: <div id="container_background"> <div id="content"> <p> #container </p> </div> </div> This is the CSS code that applies to the above HTML ...

Identifying the moment when attention shifts away from an element

Is it possible to detect when focus occurs outside an element without relying on global selectors like $(document), $(body), or $(window) for performance reasons? If achieving this without global selectors is not feasible, provide a provable reason expla ...

The controller is failing to effectively showcase the ng-show functionality

My webpage consists of three elements: a search bar, a search result area, and a form. The use case scenario involves showing the search bar and form div by default, while hiding the search result div. When I enter keywords into the search bar, client data ...

Responsive Bootstrap column with a fixed-width card

My Bootstrap-card is currently not adjusting its width properly. I want the card to occupy the full width of the column it's in. Below is a snippet of my code and a screenshot showing the current width along with the desired width indicated by a blue ...

What is the best way to merge multiple attributes into a single attribute in HTML?

Is there a way to set a margin for a section of my site without it treating each attribute individually? I want to treat them as one attribute instead. Here's an example: <div style="background-color: grey; padding: 13px;"> <h1>This p ...

Unclear about how inheritance works with the general sibling combinator "~" (tilde)?

When attempting to color list items in an unordered list using the general sibling combinator, nothing seems to happen: http://jsfiddle.net/bkbehpv0/ p { color: blue } h1 ~ li { color: red; } <h1> Title of site </h1> <p> Text in t ...

Tips for designing websites using HTML and CSS

current result: https://i.sstatic.net/eXLPv.png desired output: https://i.sstatic.net/vgl6z.png I am aiming to center the text. add image description here add image description here ...

Replace the single text area with multiple div elements and update the image within each div

Within the 'Pinctitle' area, there is text that I want to change each time a Pselectorbutton is hovered over with a fading effect. Additionally, I would like the image inside the 'Pselectorbutton' to change at the same time. Currently, ...

Tips for eliminating the border surrounding the entire table in Material-ui

Is there a way to edit a table in Material-ui without displaying it as a card? I'm looking to remove the border around the entire table, but I couldn't find any information on how to do that. Can someone help me out? Here is a link about the com ...

Tips for preventing a column from extending beyond the edge of the browser window during resizing

Issue arises when I resize the browser window, causing the left box to extend beyond the browser boundary, making it impossible to see the contents even with the scrollbar below. <!DOCTYPE html> <html lang="en"> <head> ...

I need clarification on the following: content:''

I have a question regarding this particular code snippet .store { display: block; position: relative; } .store:before, .store:after { display: block; position:absolute; content:''; } .store:before { background: url(store-before.png); ...

What is the best way to horizontally center my HTML tables and ensure that they all have uniform widths?

I'm currently facing an issue where I'd like to center align all tables similar to the 'Ruby Table.' However, I'm unsure of how to achieve this. You may also observe that some tables have varying widths. What CSS rule can I apply ...

Stop Sass from including property entirely

Within my current project, I have implemented a sass-mixin that looks something like this: mymixin.scss: @mixin customized_mixin($header-border-top-stack, $header-border-bottom-stack) { #some-id { border-top: $header-border-top-st ...

Utilizing JavaScript to arrange the dots around the circle proves to be glitchy

I am having trouble positioning dots around a circle. The top and bottom points are not aligning properly, resulting in a buggy display. What could be causing this issue? How can I fix this problem? $(function(){ var globe = $('#center') ...

Display Text Using a Variety of HTML Styles

Is there a way to achieve the following setup: HTML: <p>ABC</p> Output: DEF I am inquiring about this because I need to create an email template that includes the HTML snippet must contain <p>${__VCG__VAL__FIRST_NAME}</p> (where ...

How can you turn a SWFObject into a clickable link?

Is there a way to create a clickable link using a .swf flash file with swfObject? I want the entire video to be clickable, but I'm struggling to figure out how to do it. If you take a look at this example here: , you'll see that they were able ...

Creating a toggle link with 5 different states in coding

I have an HTML table where certain TDs contain inline styles, title tags, and links. I am looking to implement a feature where users can hide these elements by clicking the same icon multiple times. For example, on the first click, only styles are removed, ...