Add a pop of color to the container by applying a background color over the background

I am currently using the bootstrap4 framework to build this page, and I would like to incorporate a blue background color to the div that has the "globe-img" class. I attempted to achieve this by wrapping the content in an inner div (an overlay), but it resulted in breaking the grid layout completely. Is there a way to apply the background-color without adding extra markup?

html, body {
  margin:0;
  padding:0;
}
.globe-img {
  background: url('http://binarytheme.com/BTlivedemos/2014/10/20/blue-landing/assets/img/earth.jpg') no-repeat center center;
  -webkit-background-size: cover;
  background-size: cover;
  min-height: 400px;
}
.smicon {
  border: 1px solid #fff;
  height: 80px;
  width: 80px;
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">

</head>
<body>
  <div class="container-fluid globe-img">
    <div class="row">
        <div class="col-md-6 offset-md-3">
            <h1 class="text-center text-white text-uppercase pt-5 pb-4">Design my way</h1>
            <p class="text-white">Nunc at viverra risus. In euismod quam ac dictum varius. Nunc at viverra risus. In euismod quam ac dictum varius. Nunc at viverra risus. In euismod quam ac dictum varius. Nunc at viverra risus.</p>
        </div>
    </div>

    <div class="row">
        <div class="col-md-3 d-flex flex-column align-items-center">
            <i class="fa fa-android fa-3x text-white smicon rounded-circle d-flex align-items-center justify-content-center my-5" aria-hidden="true"></i>
            <p class="text-white">Android</p>
        </div>
        <div class="col-md-6">
            <img class="img-fluid" src="http://binarytheme.com/BTlivedemos/2014/10/20/blue-landing/assets/img/new-i.jpg" alt="">
        </div>
        <div class="col-md-3 d-flex flex-column align-items-center">
            <i class="fa fa-apple fa-3x text-white smicon rounded-circle d-flex align-items-center justify-content-center my-5" aria-hidden="true"></i>
            <p class="text-white">Iphone</p>
        </div>
    </div>
</div>
</body>
</html>

Answer №1

Sure thing!

Here's the code snippet to apply the overlay:

.picture-frame {position: relative;}

.picture-frame::before {
 content: ""; 
 background-color: rgba(255, 127, 80, 0.8);
 position: absolute;
 top: 0;
 left: 0;
 width: 100%;
 height: 100%;
}

.picture-frame > div {
 position: relative;
 z-index: 10;
}

Answer №2

To give the globe-img class a blue background, simply include the following code snippet:

.globe-img {
  background: blue url('http://binarytheme.com/BTlivedemos/2014/10/20/blue-landing/assets/img/earth.jpg') no-repeat center center;
}

It is not necessary to add any additional inner divs or elements to achieve this blue background effect.

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

What is the best way to modify an image in a column when I hover over a table row that was dynamically inserted using a button function?

Is there a way to dynamically change an image in a column when hovering over a table row that was added through a button function? Here is the current code that I am using, but it does not seem to work as intended when I hover over the row. This function ...

Tips for avoiding content appearing beneath overlapping elements

I am facing an issue with a hero image that has an overlapping box. I want to add content below the box but it ends up appearing behind the box. How can I ensure that the content shows below the box while maintaining responsiveness? .shell { display: ...

jquery form submission issue unresolved

I am currently utilizing jQuery version 1.10.1 and here is a snippet of my HTML code: <li> <a href='' id='logout'>Log Out</a></li> <form id='logout_form' method='post'> <i ...

Ensure that input field is validated only upon clicking the save button in Angular framework

Can anyone suggest the most efficient method to validate required fields in an input form using AngularJS? I want to display an error message only after the user clicks the save button (submit). Thank you in advance. ...

The element's height appears to be fluctuating unexpectedly when I attempt to adjust it using percentage values within a narrow range

I'm utilizing React and Bootstrap in this project. Here's an overview of my code: I have an element with height set to 0, in rem. My goal is to make the height of this element increase as I scroll down the page, creating the illusion that it is ...

No departure animation employed - Polymer

I am working on a project that involves animating a paper-icon-button with spin and opacity effects when hovering over an image using the on-mouseenter and on-mouseleave events. Everything works smoothly when hovering over the image, but I am facing an is ...

Issue with footer position not remaining at the bottom of the page

Hey there, I've been experiencing some issues with my website's layout. I tried setting a min-height of 1000px on the mainbody to make all the pages the same size, but it's caused a problem with my footer. Now, the footer is positioned in th ...

Having trouble with my custom dropdown selector conflicting with Bootstrap 4 CSS

After searching for an alternative to the typical dropdown selectors, I stumbled upon a neat custom version on W3schools. However, I encountered an issue where it clashes with bootstrap. Despite including select: hide; in the CSS, the original dropdown sel ...

The ability to use the backspace and Ctrl + c (Copy) functions is restricted in input fields on FireFox

I have a form with input fields designed using semantic UI. I need the input field to only accept numbers, remove spaces, and allow copying from it using ctrl +c. After some investigation, I found this jQuery code that seems to satisfy my requirements per ...

Having trouble with Append() function not functioning properly within the if statement nested inside a .each loop in jQuery

Looking to add text after the 4th element in a ul li? I tried using the append function, but it's appending before every li element. Here's the HTML: <ul class="gallery"> <li><a href="#">Some Text</a> ...

The design of iOS7 Safari becomes distorted when the orientation changes and an input field is in focus

It appears that there is a major issue in iOS7 on iPhone and iPad devices, and possibly on other versions as well. When you focus on an input field, causing the keyboard to open, the layout experiences a severe and irreversible disruption upon changing or ...

Modifying the maximum length of input fields in HTML, Javascript, and PHP is possible by adjusting the value through

Hi there, I'm facing an issue that should be easy for you guys to help me with. I recently discovered a security flaw while using the maxlength function in HTML. Users can easily modify the maxlength attribute by inspecting elements on the website, wh ...

The text alignment function of justify is not functioning properly

Trying to find a way to validate the content of this article, but I'm hitting a roadblock... <p style="text-align:justify;" class="custom-article"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt velit vitae risus t ...

TinyMCE generates HTML code with embedded tags

Hey there, I'm currently facing an issue with TinyMCE that I just can't seem to solve. I've browsed through some related posts but haven't found a solution that works for me... For example: When I input something in my back office, ...

Selecting options using AngularJS to parse through a list

I am faced with a challenge involving a collection of strings representing years. Here is an example: $scope.years = ["2001", "2002", "2003", ...]; My goal is to display these values in a select tag within a web page. However, whenever I attempt this usi ...

the combination of class and type functions as a jquery selector

<button class="actionButton default" type="submit"> Save</button> Can you select this button by both its class and type using a jQuery selector? I attempted the following, but it did not work: var saveBttn = $('.actionButton.default [ty ...

Code in JavaScript that shows only a portion of the selected option in a dropdown menu

I'm just starting to learn Javascript and I'm looking to create a script for a select tag that displays countries and their phone codes. My goal is to have the dropdown menu show both the country and code, but once the user selects an option, onl ...

Adjusting the spacing of the first letter using CSS, leave room

I'm encountering issues with the alignment of titles and text using the 'Lato' Google font. It seems like there is a space or kerning issue on the first letter causing them not to align properly to the left. Any suggestions on how to fix thi ...

How to efficiently center a jQuery Mobile Dialog on the screen using custom dimensions

I designed an app using jQuery Mobile and I'm looking to display a Dialog box when a button is clicked. The Dialog box should be centered on the screen with specified width and height. For reference, you can view the current version on jsfiddle. The ...

Is there a specific HTML tag available to instruct the browser to cache my HTML and/or CSS files for future use?

Up to this point, my research has indicated that enabling JavaScript and CSS browser caching typically requires server side settings such as .htaccess. Is there any HTML tag or configuration within the HTML page or JavaScript that can instruct the browse ...