Using the background-cover property in Chrome may create an extra 1px blank line

My div has a background-cover attached to it, but I'm having issues with Chrome as it sometimes adds a blank line (either horizontal or vertical, depending on the image).

Here is my HTML code:

<div class="div_image"></div>

And here is my CSS code:

.div_image {
    width: 100px;
    height: 100px;
    border: solid red;
    background: url('http://2.bp.blogspot.com/-v7UK1A8fw3A/UJXR5Vc5RjI/AAAAAAAAHuY/aWzZuSv8-jI/s250/Laika.jpg') no-repeat center center; 
    background-size:cover;
}

If you'd like to see an example of this issue, check out this link.

Answer №1

Hey there, just wanted to share that I tried this out and it was successful,

.img_container {
    width: 200px;
    height: 200px;
    border: solid blue;
    background: url('http://example.com/image.jpg');
    background-size: contain;
}

I went ahead and took out the (no-repeat center center) part from the background property.

Cheers!

Answer №2

In Chrome, I am not seeing a blank line, but it seems like there may be an issue with the image. The URL provided in the div tag appears to be out of place and could potentially be causing issues in your browser.

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

When the image transitions, the second dot does not activate

Recently, I developed a small automatic image slider that transitions to a new image every 4 seconds by utilizing the following code: setInterval(displayImage, 4000);. The image transitions are functioning correctly; however, there seems to be an issue w ...

Incorporate the jQuery hyperlink into the text being returned

I am currently working on integrating two jquery plugins into my application. The goal is to have the server return text containing a form button when a user triggers an ajax event, and then have the plugins (specifically a jquery calendar) become operatio ...

Preserve the location of a moveable div using jQuery

I have implemented draggable divs in my JSP page, allowing users to move them around freely. After dragging the divs, I would like to save their positions either in a cookie or database for future reference. Could you please advise on the best way to ach ...

Interactive Vue.js canvases that adapt and respond to various

I am currently working on adjusting my canvas to fit within its container in a Vue component. When I call resizeCanvas() in the mounted hook, I notice that the container's height and width are both 0. How can I create a canvas that dynamically fits it ...

Elevate your design game by mastering CSS transformations for precise element

I am trying to center a div with a variable width using the following code: div { background: red; max-width: 400px; position: absolute; left: 50%; transform: translateX(-50%); } Check out my demo here While this code works well for centering, ...

Arranging a pair of buttons from separate forms to be perfectly aligned on the same line

I have a page called edit.ejs for editing camps. This page contains two forms, one for submitting edits and the other for deleting the camp. Each form has a button, and they are currently displayed below each other. How can I align the buttons so that they ...

Adjusting the columns of two tables when one table is held in place

My dilemma involves managing two tables: In the scenario, Table 1 remains fixed in place serving as a header that is always visible. Meanwhile, Table 2 acts as the data table. I am not a fan of fixed widths for my tables; I prefer them to dynamically adj ...

Creating a visually appealing website layout using HTML and CSS to align DIV

I'm having trouble with the CSS aspect of my portfolio website design. I'm trying to create a layout like this: Here's what I have so far: body { margin: 0; padding: 0; } .menu { height: 100vh; width: 380px; background-color: # ...

Adding a border to my image that extends to the edges of the page

.overlay{ position:absolute; top:0; left:0; height:100%; width:100%; background:url(hex-shape.png) no-repeat center; z-index:99999; } I have created an overlay background image that covers the entire page. I want the area surrounding the ove ...

Techniques for animating background image using jQuery

Hello there! I'm currently experimenting with animating a background image using jQuery. Despite following a tutorial, I haven't been successful in getting my test page to work as intended. The blue Facebook icon displays, but it doesn't ani ...

Issue with readonly is preventing the ability to alter the font color of the input

I need to change the font color of a disabled input. When it is disabled, it appears gray and I want it to be black instead. I attempted to use readonly but that did not have the desired effect, and now the input is showing [object Object]. Below is my HTM ...

Using OwlCarousel navigation to display cards with left and right controls in a React.js application

I am attempting to incorporate the use of owl-carousel. My goal is to display one item at a time and include next and previous buttons on the left and right sides of my cards. I'm unsure how to achieve this, so any assistance would be greatly apprecia ...

Customize Your Wordpress Category Title with a Background Image

Within my wordpress template, there is a module known as new_boxs. The code snippet below shows that this module displays on the page six times, with two columns wide and three rows down: foreach($data_cat as $cat){ ?> <div class="span6"> ...

Your unique way of typing out your thoughts

This is an example of typing code using jQuery. How do I customize my own style? For example, I want to write a text like this: Hi. My <span style="text-decoration: underline;">name</span> is <span style="color: #ff0000;">Amir</span ...

Guide to horizontally centering the main div with a div positioned to its left

Seeking the most effective method to achieve the following layout: --------------------------|-------------------------- | | | -------- ------------------------- | | | menu | | ...

What steps can I take to ensure that the v-main element occupies at least 70% of the viewport height in Vuetify?

As a newcomer to Vuetify, I am still learning the ropes. One thing I've noticed is that <v-main> automatically expands to fill the space between <v-app-bar> and <v-footer>, taking up the entire viewport height. My concern arises wh ...

Creating fixed and scrollable columns using either Flexbox or Bootstrap

I'm currently facing an issue with creating a responsive webpage layout. My goal is to have a fixed left column that consists of an image taking up 66% of the page, with the remaining 33% dedicated to scrollable content on the right side. To achieve t ...

List with Columns for Organization

I am not seeking advice on how to use columns in lists, but rather on aligning the columns on my website. Below is the code I have: <ol class="threecolumns"> <li>Item 1</li> <li>Item 2</li> <li>Item 3< ...

Issue with z-index in Internet Explorer version 7

Currently, I have implemented a drop-down list using jQuery that activates when the user hovers over the main menu. This functionality is working appropriately in all browsers except for IE7 and earlier versions. In an attempt to ensure the drop-down menu ...

CSS DROP DOWN NAVIGATION MENU - Struggling to maintain hover effect on main menu item while navigating through sub-menu

I am facing a challenge with a CSS-only drop-down menu where the top main menu item loses its highlight when I move the cursor over the sub-menu items. You can view the menu in action here: . For example, if you hover over "Kids" and then move your cursor ...