Placing an image in context with the background image

Looking for guidance on CSS styling. I have successfully set up a responsive background image on my page and now want to add a circular logo positioned at the bottom center of it. However, I am facing an issue where the logo's position changes when the screen size is adjusted. I need help making sure the logo stays in the same spot regardless of the view size.

I've tried adjusting the padding and positioning of the image, but these settings are not responsive. The image moves up when the screen is smaller and down when it's larger. My goal is to keep it static.

Feel free to check out my latest attempt on this fiddle:

https://jsfiddle.net/ybeuvn9m/

Here's the code snippet:

    <div class="container-fluid">
  <div class="row">
    <div class="splash col-sm-12">
      <div class="photo">
        <img class="img-responsive img-circle logo" src="http://i.imgur.com/Dum5A8J.png">
      </div>
    </div>
  </div>
</div>

.logo {
  padding-top: 200px;
  width: 10%;
  margin: 0 auto;
  display: block;
}

.splash {
  background: url('http://s169923.gridserver.com/images/IntelligentsiaMocha.jpg');
  background-repeat: no-repeat;
  background-size: cover;
  height: 50vh;
  background-color: rgba(0, 0, 0, 0.2);
  background-blend-mode: overlay;
}

Answer №1

To ensure that an .photo always remains centered within .splash, you should utilize Flex-box.

Include the following snippet in your code:

.parentDiv{
  display: flex;
  justify-content: center;
  align-items: center:
}

Visit this link for a comprehensive guide to Flexbox.

Answer №2

If you want to position it absolutely within the main image div, we can make some adjustments to achieve that. Check out the modified version of your JSFiddle here: https://jsfiddle.net/jameson5555/ybeuvn9m/1/

Below are the updated .logo styles. Also, remember to include position: relative in your container to establish a relative position for the .logo inside it.

.logo {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 40px;
    margin-left: -20px;
    display: block;
}

Answer №3

.brand { 
        margin-top: 80px; 
        width: 120px;
        padding: 0 auto;
        display: inline-block;
      }

Ensure your brand logo maintains a consistent width throughout.

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

Images in CSS not copied to the output directory when using Webpack

Using Webpack to bundle various javascript and css files on a website includes bundling bootstrap.css and chosen.css as part of the bundles. To achieve this, there is a main.js file serving as an entry point for importing all necessary files. The process i ...

Achieve horizontal bar movement by utilizing google.visualization.DataTable in a left-to-right motion

I am exploring the possibility of reversing the direction of a chart(bar) using google.visualization.DataTable. In the current setup, the bar progresses from left to right, but I wish for it to move from right to left instead. Below is what I have attempte ...

Comparison between Mobile Phone's innerWidth and innerHeight Versus Resolution

My test phone, the Galaxy S3 Mini, has a resolution of 800x480 according to its specs. Strangely, when I run the following code in my HTML game: window.innerWidth window.innerHeight The width appears as 533 and the height as 295. I recently discovered ...

Save the Selenium HTML source code into an HTMLDocument element

Is there a way to save the HTML code fetched using Selenium (via Excel VBA) into an HTMLDocument element? The following example demonstrates utilizing Microsoft Internet Controls and Microsoft HTML Object Library for automating Internet Explorer. Dim IE ...

Creating multi-level nested lists with numbering using HTML and CSS

Is there a way to create a unique numbering format using only HTML and CSS lists (<ul> or <ol>)? 1. Item A 2. Item B 3. Item C 3.1. Subitem C.1 3.2. Subitem C.2 3.3. Subitem C.3 4. Item D 4.1. Subitem D.1 4.1.1 Sub-subi ...

The problem arises when trying to use the Jquery click event on buttons that have been generated

I've encountered an issue where I can create components dynamically, but the click event doesn't seem to work on buttons that are dynamically generated. Check out the code snippet below: HTML file: <div class="merge_sections">&l ...

Is there a way to always keep an element positioned directly above a fluid image that is perfectly centered?

My current project involves creating an overlay to display a fluid image of any size. The challenge I'm facing is how to consistently position the close button 30px above the image and flush with its right edge. The catch is that the container doesn&a ...

Tips for positioning buttons using HTML and CSS

Looking for some help with my HTML page design. I have a few buttons that I want to style like this: https://i.stack.imgur.com/3UArn.png I'm struggling with CSS and can't seem to get them positioned correctly. Currently, they are displaying "bel ...

Set up an event listener for a specific class within the cells of a table

After spending the last couple of days immersed in various web development resources, I find myself stuck on a particular issue. As someone new to this field, the learning curve is quite steep... Let's take a look at a single row in my project: < ...

Creating a new project in ASP Net Core Angular using Bootstrap 4 for the SideMenu layout instead of Bootstrap 3

I am currently working on developing a website using Angular6, where I aim to have a vertical navbar for large screens and a top navbar with dropdown functionality for mobile devices. While searching online, I came across several examples that seemed overl ...

Is there a way to prevent elements from resizing when zooming in or out?

What is the best way to prevent elements from resizing on a standard website when users zoom in (CTRL +)? ...

Generate a dynamic animation by combining two images using jQuery

My attempt to animate two images is not working. I received some help on Stack Overflow but still facing issues with my CSS and HTML code. This is the code I am using: $(document).ready(function() { $(".animar").click(function() { $("#img4" ...

Styling hover effects on links in Bootstrap 4 with underlines

In Bootstrap 4, the anchor tags have the text-decoration: underline; property added only on hover. Is there a pre-existing helper or utility class to remove this underline? I went ahead and created my own helper class in CSS to remove the underline, but ...

I am looking to save the session value into the search box of the appTables application by utilizing jQuery

Is there a way to save the session value in the search box of appTables by using jQuery? <?php $session = \Config\Services::session(); ?> <script type="text/javascript"> $(document).ready(function () { var searc ...

What is the best way to disable the button hover effect after it has been clicked?

Many posts I've come across have similar issues to mine, but the suggested solutions are not working for me. I am struggling to remove the hover property of my button when it is clicked before triggering the removal event I have set up. Edit: Just t ...

Storing parent entity along with child entities containing selected properties using ASP.NET Core MVC

Working on an ASP.NET Core MVC web app, I encountered a problem that can be best explained through this example: Let's consider a scenario where the user needs to save information about a book including its title, number of pages, and one or more aut ...

Manipulating video volume using JavaScript injection

My web page includes a video, and I have successfully used JavaScript injection to control the play/pause functionality. Now, I am looking to also adjust the volume based on percentage. How can I create a function that decreases or increases the volume acc ...

I'm having trouble getting my login page centered when using Semantic UI

Currently, I am working on creating a login page using Semantic UI. However, I am facing an issue where the column is not aligning to the center as intended; instead, it is occupying the entire page. I have attempted to link all the necessary files in the ...

selenium tutorial: accessing checkbox state for frost

There is a frost checkbox that I have defined as follows: <div id="protocol_input" class="ember-view frost-checkbox small"> <input id="protocol_input" class="input ember-view" type="checkbox"> <label class="label" tabindex="0" for="proto ...

How can you deactivate all form elements in HTML except for the Submit button?

Is there a method available to automatically deactivate all form elements except the submit button as soon as the form loads? This would entail pre-loading data from the backend onto a JSP page while restricting user access for editing. Users will only be ...