How do I add margin to just background image?

background image padding
css background image size
background image position
background image padding css
background image padding-top
background images contain
background-position not working
table background image size

I want to add a margin to the background image so that I distance it from the middle of the screen, but adding it inside that class adds a margin to the whole body.

body.poppage {
    background: url(/Imagenes/tip3.png) 50% 200px no-repeat #E2E4E9;
}

How could I do it? Thanks

you can use the background-position property

css - How do I add margin to just background image?, background: url(images/header-bg.png) repeat-x #000; If you could post the HTML, or just upload it somewhere so we can look that would  Background position, margin-top? If you mean you want the background image itself to be offset by 50 pixels from the top, like a background margin, then just

Use the containers padding to make a kind of margin for the background.

<div class="thebox">
    <p>HEY!</p>
</div>

div.thebox
{
box-sizing: border-box;
width:400px;
height:400px;

border: 2px solid #000000;
padding: 10px;

background: url(http://studio-creator.com/blog/public/html5.jpg) center;
background-size: contain;
background-repeat: no-repeat;
background-origin: content-box;
}

https://jsfiddle.net/gann1pwm/

[Solved] Background Image and Margin Problem, The background-position property in CSS allows you to move a background This places your background image at the top left of the container. You can only do this if you're exclusively using keywords, though. center What if I want the image to be centered right with some margin-right of about 20px? CSS Margins. The CSS margin properties are used to create space around elements, outside of any defined borders.. With CSS, you have full control over the margins. There are properties for setting the margin for each side of an element (top, right, bottom, and left).

this work with me i have 50px navbar

background-size: contain !important;
background-repeat: no-repeat !important;
background-position: 0 50px !important;

background-position, Tip: By default, a background-image is placed at the top-left corner of an center bottom, If you only specify one keyword, the other value will be "center", Play it  You can't really add margins to a background image, since it's not actually an element. A couple things you might try: If you've got a containing element just inside the body, you can apply the background image to this element and set margins on it.

You might want to try something else... like moving the image to the next child. You can make a wrapper div around your fixed-width div to accomplish this task.

CSS background-position property, How do I move a background image to the right? The background-image property sets one or more background images for an element. By default, a background-image is placed at the top-left corner of an element, and repeated both vertically and horizontally. Tip: The background of an element is the total size of the element, including padding and border (but not the margin).

You can't really add margins to a background image, since it's not actually an element. A couple things you might try:

  1. If you've got a containing element just inside the body, you can apply the background image to this element and set margins on it.

  2. If all you want is to make the background image appear to be floating within its container, set its background position.

Offset a background image from the right using CSS, How do I change the background color of my margins? The first value is the horizontal position and the second value is the vertical. The top left corner is 0 0. Units can be pixels (0px 0px) or any other CSS units. If you only specify one value, the other value will be 50%. You can mix % and positions. Sets this property to its default value. Read about initial.

Margin color sorrunding the site, of that (it's in the style tags in the head of your html doc). You do not have to have the image in the solution's folder. Stick to answering new questions where the OP still needs help and make sure your solutions are accurate Add a Solution

How to position a background image, p> <p>Now the background image is only shown once, and positioned away from the text.</p> <p>In this example we have also added a margin on the right  I am struggling with trying to add a background image to just the no-header page type in a theme that otherwise doesn't have this. The image is already uploaded to my assets folder. I've attempted to do this using suggested code/instructions in CSS alone, html alone and the two in tandem (based on suggestions online).

CSS - Background Image Overflow! - HTML & CSS, Keeping the inner width, you could extend the background width by padding and soak If the div is 100px wide and the background image 1800px wide than only to me like you just need to put the background image on the body element.

Comments
  • but background position counts pixels necessarily from the left or right of the screen right? There is not way to start counting from the middle?
  • Create a container with this background, and center it on the page
  • Very good example background-origin usage! Might be worth adding an explanation on why it's there (to make position relative to content, rather than to the padding edges as would be the default)
  • This is brilliant, I didn't know about "background-origin: content-box;". Thank you!