/    Sign up×
Community /Pin to ProfileBookmark

DIVs will not expand for a background image?

Hi all,

It seems when I throw elements in to a DIV of unspecified size, the DIV will expand to accommodate the new element. *EXCEPT* a background image.

Is this just one of those rules of CSS? A DIV of unspecified size will not expand for a background image? Is a background image not classed as an element? Is there reasoning to this?

Thanks.

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisFeb 20.2007 — The background-image is style element, not an HTML element that takes up space in the browser. It is not part of the document flow.
Copy linkTweet thisAlerts:
@callumdauthorFeb 20.2007 — I see.

What is the difference between an HTML element, and a style element? Because one can apply styles to a background image... no-repeat, positioning, etc.
Copy linkTweet thisAlerts:
@gil_davisFeb 20.2007 — one can apply styles to a background image... no-repeat, positioning, etc.[/QUOTE]No. The background-image is part of the style definition for an HTML object or element. You are applying the styles to the HTML object, not the image (one of the reasons that background-image gets a URL definition rather than SRC, I suppose). The image doesn't really exist in the document flow, it is "eye candy".

CSS allows setting position, repeat and attachment, but not size.
Copy linkTweet thisAlerts:
@callumdauthorFeb 21.2007 — I see.

Thanks Gil.
×

Success!

Help @callumd spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...