What could be causing the leftward movement of my hovering image?

I'm seeking a solution for my image overlay text shifting issue. Currently, when I hover my mouse over the image, the overlaid text moves to the left by 69 pixels instead of staying directly above the image. How can I rectify this problem?

https://i.sstatic.net/ZVeJg.png

HTML

<div class="row">
     <div class="container col-lg-3">
        <img src="Images/Coding.jpg" alt="" class="image">
     <div class="description">
        <h6 class="titles">
            Coding
        </h6>
        <br>
        <i class="far fa-keyboard fa-2x"></i>
        <br>
        <br>
        <p>
            Projects | Learning | Design
        </p>
    </div>
        <div class="overlay">
          <div class="text">
                <h5>
                    Take a peak at my offers, current projects, and qualifications
                </h5>
                <br>
                <a class="btn btn-outline-light btn-sm" href="coder.html" role="button">
                    Explore more
                </a>
          </div>
        </div>
      </div>
</div>

CSS

.container {
position: relative;
width: 250px;
height: 250px;
}

.container:hover .overlay {
opacity: 1;
}

.image {
display: inline-block;
width: 250px;
height: 250px;
}

.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 250px;
width: 250px;
opacity: 0;
transition: .5s ease;
background-color: #008CBA;
}


.text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}

Answer №1

Since the container class is applying padding, it's important to include padding:0px;

.container {
    position: relative;
    width: 250px;
    height: 250px;
    padding:0px;
}

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

Employing ajax with dynamically created buttons in PHP

I'm struggling to figure out what to search for in this situation. I've tried piecing together code from others, but it's just not working for me. My ajax function successfully retrieves data from a database through a php page and displays ...

Send two values from a select box when it is chosen

I am currently facing a challenge where I need to retrieve two related values when a select box is changed. The select box is set up to allow multiple selections and contains options that represent user resources, some of which are parent resources. My goa ...

Error message: The function Vue.use is not being caught as a TypeError

Recently, I've started learning VueJS and now I'm attempting to swap out the <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="89fffcecc9bba7bf">[email protected] ...

CSS overflow property determines whether to display or hide the parts of an element

Is it possible to create HTML text that will automatically hide itself entirely if it exceeds the container size, instead of clipping with the overflow: hidden property? ...

Utilize CSS to format the output of a script embedded within

When I embed the following script in my HTML, the output doesn't have any styling. How can I style the script output to blend well with the existing HTML structure? I tried accessing the output by ID, but couldn't figure it out. <script> ...

Fluid background images frame the header on either side, with a void of background in the center

I am in need of a header that spans the entire width and is divided into 3 columns, with background images only in the 1st and 3rd columns. Cross-browser compatibility is crucial for this solution. The first column should have a background image and be ...

What is the actual purpose of the <header> and <footer> elements in web design?

Why are headers and footers important on a webpage? Considering that they appear in the order they are written on the page, as shown here, what distinguishes a header from a footer? <article> <footer>This is a footer</footer> &l ...

How can I select a checkbox using jQuery?

I need help toggling a checkbox on and off using jQuery. Here is the HTML code: <input type="checkbox" id="isWorking" name="isWorking" /> I attempted to control it with jQuery like this: $('#isWorking').prop('checked', true); $ ...

Stay afloat at the bottom of the webpage without using xhtml

Currently working on Moss 2007 and in need of creating a floating button at the bottom of the screen. This button should move down as I scroll down and up when scrolling back up. Although it can be easily achieved with xhtml, the challenge lies in not bei ...

Graph is vanishing while linked

A unique HTML canvas is included in a standalone file called dashboard.html. To display the dashboard on the main homepage (home.html), we utilize ng-view nested within an ng-if directive. Oddly, clicking on the hyperlink "#" from the home page causes th ...

Add option button

Is there a way to dynamically add radio buttons using jQuery or JavaScript and save the data into a database? I have successfully appended input types such as text, textarea, checkbox, and select with options. Here is my code: <!DOCTYPE html> < ...

Guide to configuring the overflow-y property for individual cells or rows in a Bootstrap-Vue table

Hello there, I am currently using Bootstrap-vue to display data that has been queried from a database. My goal is to have it displayed with an overflow-y style similar to this image. If you know how to achieve this effect, please share your solution. Here ...

Having trouble accessing the value of a node in JavaScript, as it keeps returning as "null"

Experimenting with converting HTML elements into lists. The objective is to generate a list of all values in a table upon clicking the "page next" buttons on it. Afterward, an alert should display the value of the first item in the list, which corresponds ...

Another element concealing an element underneath

I am currently working on a website and could really use some assistance. Being new to web design, I find myself puzzled by this particular issue. The problem I'm facing is with a sawtooth pattern that should be displayed over a header, similar to the ...

Tips for setting the color of hyperlinks in a UIWebView

I'm struggling with formatting a short plain text string, which may include a weblink, in a UIWebView. When I use loadHTMLString, the font style and size appear incorrect. After searching extensively, I ended up embedding the text in a makeshift HTML ...

Developing a custom styling class using JavaScript

Looking to create a custom style class within JavaScript tags. The class would look something like this: #file-ok { background-image: url(<?php echo json.get('filename'); ?>); } Essentially, the value returned from the PHP file (json ...

The necessary attribute is malfunctioning. (HTML)

I am currently working on a signup page utilizing HTML and JavaScript. Everything was running smoothly until I added a function to navigate the user to the next page. The issue arises when the textboxes are left blank; upon clicking the button, the user is ...

Sketch a line extending from one element to the next

Is there a way to create a styled line that starts from the center of one <td> element and ends at the center of another? I attempted to use the jQuery Connections plugin but it only connects the edges of the elements, not their centers. The plugin ...

Update the color of the angular material input text box to stand out

Hey there, I'm currently using Angular Material and I want to change the color of the input focus when clicked. At the moment, it's displaying in purple by default, but I'd like it to be white instead. https://i.stack.imgur.com/vXTEv.png ...

Which is better for SEO: using H tags or image alt text?

In need of a major website title that stands out. Which SEO solution reigns supreme? Implementing an image with alt text "my crucial page title" Utilizing h1 tags for the "my crucial page title" text ...