Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS background-position top right corner

Tags:

html

css

I want icon background image on a button to appear at the top right corner.

I successfully used background-position: bottom top 100px to move the image to the top, but I have been unsuccessful moving the image to the right.

Is there something similar to background-position: bottom top 100px, right 900px that might help produce the desired results?

#AddNewMeetingButton {
    position: absolute;
    top: 0;
    text-align: center;
    background-image: url(Images/add_icon_48x48.png);
    background-position: bottom top 100px, right 800px;
    background-repeat: no-repeat;
    height: 190px;
    width: 915px;
    background-color: transparent;
    outline: none;
    border: none;
    z-index: 2;
}
like image 610
Spencer H Avatar asked Aug 19 '15 14:08

Spencer H


People also ask

How do I move a background image to the right in CSS?

Give it a shot. Essentially, background-position: 90% 50% will make the right edge of the background image line up 10% away from the right edge of the container. Create a div containing the image. Explicitly set the position of the containing element position: relative if not already set.

How do I put an image on top right background in HTML?

You could try: background-position: right top; If you need a margin add it to the image. Almost, but margin won't affect a background image.

How do I put an image on top of corner in CSS?

Try using float: right; and a new div for the top so that the image will stay on top.


2 Answers

Something like this

background-image: url(http://i.stack.imgur.com/cW9aK.png);
background-repeat: no-repeat;
background-size: 48px 48px;
background-position: right 10px top 10px;

JSfiddle Demo

MDN Reference

background-position:<position> where:

<position> is one to four values representing a 2D position regarding the edges of the element's box. Relative or absolute offsets can be given. Note that the position can be set outside of the element's box.

So:

background-position: right 10px top 10px;

puts the image at the top / right but 10px away from the right edge and 10px from the top edge

like image 102
Paulie_D Avatar answered Oct 13 '22 02:10

Paulie_D


You could try:

background-position: right top;

If you need a margin add it to the image.

like image 38
germanfr Avatar answered Oct 13 '22 04:10

germanfr