Creating an Overlay Effect with Images in Bootstrap 4

I am using Bootstrap 4 and attempting to create an overlay effect with a .png image that masks part of the bottom area of the first section.

The height of the .png image is 130px and it needs to remain unscaled on mobile devices.

I have experimented with using the ::after pseudo-elements with content as a background image on the first section, but this results in an unwanted bottom margin.

You can view my example here: https://codepen.io/michalwyrwa/pen/EGbxXb

Is there a more effective way to achieve this?

CSS:

body {
    color: #ecf0f1;
}

.welcome .col {
    background-color: #3498db;
	height: 50vh;
}

.welcome::after {
	content: url(https://files.tinypic.pl/i/00976/nb1abpgxj5x3.png);
	display: block;
	margin: 0;
	padding: 0;
}

.features .col {
	background-color: #6ab04c;
	height: 50vh;
}

HTML:

<section class="welcome">
	<div class="container-fluid">
		<div class="row text-center">
			<div class="col-12">
				<p class="my-3">Welcome text</p>
			</div>
		</div>
	</div>
</section>

<section class="features">
	<div class="container-fluid">
		<div class="row text-center">
			<div class="col-12">
				<p class="my-3">Features</p>
			</div>
		</div>
	</div>
</section>

Answer №1

I may not have identified the underlying issue, but I do have a solution for you.

.welcome::after {
content: url(https://files.tinypic.pl/i/00976/nb1abpgxj5x3.png);
display: block;
padding: 0;
margin-bottom: -6px;
}

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

Using jQuery to update the CSS class for all li icons except for the one that is currently selected

Utilizing Font Awesome Icons within the li elements of a ul Challenge When a user clicks on the user icon, the color changes from black to yellow. If the user clicks on another icon, that one also turns yellow. Is there a way to remove the existing yell ...

Sleek and adaptable side spacing feature

While utilizing the Neat framework, I found that the column's gutter adjusts itself based on the window size, which is a common feature of grid frameworks. In my current project, I want to utilize the gutter-width ($gutter) as padding for certain elem ...

Achieve a bottom alignment in Bootstrap without using columns

I am looking to align the elements within a div to the end, but when I use Bootstrap's d-flex and align-items-end classes, it causes the elements to be split into columns. This is not the desired outcome. How can I resolve this issue? <link href ...

A paragraph styled with line numbers using CSS

I struggle with writing long, never-ending paragraphs and need a way to visually break them up by adding line numbers next to each paragraph. While I'd prefer a solution using only CSS for simplicity's sake, JavaScript works too since this is jus ...

Utilizing modal pop-up windows to update queries in PHP

[Hey there!] I'm facing a challenge and could really use some help. I have two files, index.php and m_update_pk.php, which I include in index.php. In m_update_pk.php, I've set up a modal that should open when someone clicks on "Edit" in the table ...

Bootstrap table exceeds the boundaries of the smartphone screen

I'm currently working on my first laravel project with bootstrap (https://getbootstrap.com/) and I've encountered an issue related to mobile device responsiveness. The problem arises when using a basic table in bootstrap4 (the absence of the res ...

There seems to be an issue with the functionality of ASP.NET MVC Bootstrap

My ASP.NET MVC project is using the latest version of Bootstrap (v4.1.3), however, I am experiencing issues with dropdown components not functioning properly. https://i.sstatic.net/by8Pd.png After some troubleshooting, I tried using @Style.Render(~/Conte ...

Would you like to learn how to set an auto-play video as the background in a webpage section, similar to the one found on http://www8.hp.com/in/en/home.html?

I was browsing the HP-India website and noticed they have a cool autoplay video in the background of a section below the header. I would love to recreate something similar on my own website. Any tips on how to achieve this? ...

Webix UI - Struggling to create dynamically responsive components during screen resizing

Can anyone guide me on how to make my Webix UI control responsive in the free version available at ? It seems to be acting unpredictably due to the AngularJS integration code I'm using. I have attempted various solutions like media queries, redraw, a ...

Change the background color of a div element dynamically

Is there a way to dynamically apply a background color to only the first 5 div blocks in React? Here is my code snippet: const ImageBlock = ({block}) => { const number = 5 return ( <React.Fragment> {block.map((item, index) => ...

Assign a new class to the child element of **this**

Can you please explain how to apply a class to the child elements of this? I am looking to give a different background color to all Compliant items. For example: <div class="tab"> <tr><td class="compliance">Compliant</td>< ...

Positioning the close button on the top right edge of a Material-UI Dialog: A step-by-step guide

https://i.sstatic.net/ARTtq.png How can I include a close icon in the top right corner of the header section? I'm using the Material UI Dialog and everything works well, but I need a close button in the top section. Can anyone assist me with this? ...

create a new div at the bottom of a designated page when printing out the content

I am facing a challenge with printing a table that has a variable number of rows via browsers. I need to ensure that the table is followed by a div which remains at the bottom of each page, adjusting its position according to the table's overflow onto ...

What could be causing my jQuery script to malfunction?

After scouring through numerous Stack Overflow questions and conducting countless Google searches, I am still stumped by the issue at hand. As a beginner in web development, all I want is for this simple page to function properly. Can someone please point ...

Editable Bootstrap Accordion Title

I am currently working on creating a Bootstrap accordion using Knockout foreach, where the header is editable. The goal is to allow users to double click on the accordion name and have it turn into an input box that saves changes either by pressing enter o ...

Ways to assign numerical values to vertical bars using HTML and CSS

Is there a way to create a Y-axis style line in HTML and CSS that looks like an actual Y-axis? I've attempted the following approach, which technically works but doesn't have the desired appearance. #mySpan{ writing-mode: vertical-lr; ...

Using float instead of CSS inline-block is more effective for styling a PHP element

I've been working on styling a page that was generated with App Gini. While I have been successful in editing most elements so far, I am facing an issue with getting inline-block to work properly. Although float:left is functioning correctly, I would ...

Is it possible to blur all elements of a form except for the submit button?

Can someone help me with a form issue I am facing? <form> <input type="text>' <input type="submit">' </form>'' After submitting the form, I would like to blur the entire form: $(this).closest('form') ...

The default margin of an HTML element is set to fill the width of its containing div and cannot be overridden

As a budding web developer, I'm encountering a basic issue that has me scratching my head. Any assistance would be highly appreciated: Regardless of the width I specify for elements within a particular div container, both Safari and Chrome seem to au ...

display child element at full width within a parent element that is not full width

I have a container with a maximum width of 1024px, and I want one of its child elements to take up 100% width starting from the left edge of the screen. Is there a way to achieve this without adding extra HTML markup? I know I can make the child element 1 ...