Unwanted white space on the top and left

user11482259

I'm trying to make an image under a title on the top left but the image doesn't want to cover the left side.

I changed the position to position: absolute, made the margin and padding 0, inspected the HTML page and can't see anything that can influence this image.

The HTML:

        <div class="header">
            <div class="container">
                <div class="row">
                    <div class="col">
                        <h1>Dillan Robbertze<h1>
                        <img src="mountain-og.jpeg">
                    </div>

                </div>
            </div>
        </div>

The CSS:

.header img{
    height:Auto;
    left:0;
    margin:0;
    padding:0;
    position:absolute;
    width:100vw;
    z-index:1;
    }

Expected Results: Image is under the title top left. Actual Results: There is a white space left and top of the image.

EDIT: I added top:0; thanks to @Somesh Mukherjee. The image moved up, but there is still a left space that shouldn't be there.

Hossein Ghanaati

add a class to the parent div element. and add position relative to it.

.myNewClass {
    position: relative;
}

also, make sure your parent elements don't have margin and padding. for that, you can use a CSS reset like this:

* {
    margin: 0;
    padding: 0;
}

though this will make sure all of your elements don't have any margin or padding so you need to specify all you need by yourself. you should put this at the top of your CSS file if you want to use it.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Unwanted white space on left of UIScrollView on iPhone X

CSS - White space around top and left of page

Unwanted Top and Bottom White Space in Android Webview after keyboard disappears

HTML tag stuck to top left of mobile page with white space around it

Unwanted white space at the bottom of page

White space to the left of the image

white space in the left of the website

How to Remove Unwanted Top White Space in Mobile View on WordPress Index Page?

Unwanted white space with knitr+booktabs package

How to remove unwanted white space in CSS

Unwanted white space on right side in mobile view

Shiny R: Unwanted white space in fluidRow

transform: rotate is creating unwanted white space

Unwanted white space is breaking the layout on outlook

Unwanted White Space at the bottom of my website

Bootstrap 5 - Unwanted white space at the bottom

Unwanted white section appears on top of website

Android: Unwanted White Box at Top of Screen (toolbar?)

Expo - unwanted white bar at top with back button

White space on top of my webpage

Unwanted offset appears on left and top of the browser

Remove unwanted white space when rendering leaflet or plot in Shiny

How to remove unwanted white space in the bottom of Ionic modal?

how to remove unwanted vertical white space in visual studio 2013

Collapse Control under a GridSplitter - Unwanted White space appears

Unwanted white space under image containing entry in IE

Unwanted White Space at the bottom of Web Angular / Material / Bootstrap Page

Unwanted white space between rows when bootstrap enabled

Unwanted White Space Mobile View HTML / Burger Menu Size