background-size in shorthand background property CSS3

0 votes

I'm trying to mix background-image and background-size properties in a shorthanded background property. Based on W3C documentation background-size should come after background-position property separated with an slash(/).

W3C example:

p { background: url("chess.png") 40% / 10em gray
       round fixed border-box; } 

is equivalent to:

p {
    background-color: gray;
    background-position: 40% 50%;
    background-size: 10em 10em;
    background-repeat: round round;
    background-clip: border-box;
    background-origin: border-box;
    background-attachment: fixed;
    background-image: url(chess.png) }

MDN says same thing.

But this is not working! It also is not clear how to make a shorthand background property when background-size and background-position have two different values for background-position-x and background-position-y or same thing for background-size. It's not clear how the slash(/) takes place? 

Example I tried to make a shorthand is this CSS code:

div {  
    background: url(http://www.placedog.com/125/125) 
        0 0 /  150px 100px 
        repeat no-repeat 
        fixed border-box padding-box blue;      
    height: 300px;
    width:360px;    
    border: 10px dashed magenta;  
}

A cleaner example

This is working

 body{
        background-image:url(http://www.google.com/intl/en_com/images/srpr/logo3w.png);
        background-position:200px 100px;
        background-size:600px 400px;
        background-repeat:no-repeat;
    }

This is not working

body{
    background:url(http://www.google.com/intl/en_com/images/srpr/logo3w.png) 200px 100px/600px 400px no-repeat;
}

This is not working too

body{
    background:url(http://www.google.com/intl/en_com/images/srpr/logo3w.png) 200px/400px 100px/600px no-repeat;
}
Jul 6, 2022 in CSS by Edureka
• 13,620 points
723 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In CSS

0 votes
1 answer

How to make div background color transparent in CSS

To begin, we will build a div> ...READ MORE

answered Jun 28, 2022 in CSS by Edureka
• 12,690 points
1,821 views
0 votes
0 answers

Fading in a background image using javascript or css on hover

I have so far been able to ...READ MORE

Jun 30, 2022 in CSS by Edureka
• 13,620 points
902 views
0 votes
0 answers

Curved background image in CSS

I'm trying to achieve something like in ...READ MORE

Aug 5, 2022 in CSS by Edureka
• 13,620 points
2,696 views
0 votes
0 answers

Difference between CSS3 transitions' ease-in and ease-out

What distinguishes ease-in, ease-out, and other CSS3 ...READ MORE

Aug 19, 2022 in CSS by Edureka
• 13,620 points
284 views
0 votes
2 answers

Uncaught TypeError: Cannot read property 'setState' of undefined

Use this.delta() = this.delta.bind(this); in place of this.delta. ...READ MORE

answered Aug 22, 2020 in CSS by Abhishek
14,269 views
0 votes
1 answer

How do I give text or an image a transparent background using CSS?

Use either a semi-transparent PNG or SVG ...READ MORE

answered May 27, 2022 in CSS by Edureka
• 12,690 points
426 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
9,761 views
0 votes
1 answer

Using/Handling colon inside a JSF generated HTML element ID in CSS selector

Yes, you can.  Just Backslash (\) the colon.  Like ...READ MORE

answered Nov 14, 2018 in Others by DataKing99
• 8,240 points
2,596 views
0 votes
1 answer

What is a css selector and where is it used?

CSS Selector is a combination of element ...READ MORE

answered Nov 21, 2018 in Data Analytics by Kalgi
• 52,360 points
718 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP