/    Sign up×
Community /Pin to ProfileBookmark

background no-repeat

This background still repeats even with the no-repeat option, is the syntax incorrect?

document.write(‘<table background=”myimage.jpg” background-repeat:no-repeat
style=”width:78%; cellspacing=”0″ cellpadding=”0″ border=”4″></table>’);

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@mrhooFeb 24.2006 — the background properties are part of the element's style object,

and the attributes you applied to the style object are not:

try this:

document.write('<table width="78%"; cellspacing="0" cellpadding="0" border="4"

style="background-image:url('myimage.jpg' );

background-repeat:no-repeat" ></table>');
Copy linkTweet thisAlerts:
@ranosbauthorFeb 24.2006 — must be something wrong, nothing shows now

<table width="78%"; cellspacing="0" cellpadding="0" border="4"

style="background-image:url("myimage.jpg" );

background-repeat:no-repeat" ></table>
Copy linkTweet thisAlerts:
@KravvitzFeb 24.2006 — While mrhoo is correct in that your syntax is wrong, his code is wrong too. You can't put the same kind of quote mark in a quoted attribute value used to quote the value.

document.write('&lt;table style="width:78%;background:url(myimage.jpg) no-repeat;" cellspacing="0" cellpadding="0" border="4"&gt;&lt;/table&gt;');

Why are you using document.write() anyway?

[url=http://www.w3.org/TR/REC-CSS2/colors.html#propdef-background]CSS2 Background property.[/url]
Copy linkTweet thisAlerts:
@ranosbauthorFeb 24.2006 — Its an external script.

This works, seems it needs a height, and td & tr...

Thanks guys...

Question, can a background image be set at a certain size?

In the example below, if the image is larger than the window, it is cut off, not resized like an image in the td part of a table...??


<table style="width:78%; height:400px; background:url(humor/54.jpg)

no-repeat;" cellspacing="0" cellpadding="0"

border="4"><tr><td></td></tr></table>
×

Success!

Help @ranosb 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 6.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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