/    Sign up×
Community /Pin to ProfileBookmark

div background disappearing in IE

I am having a problem with the code below. I have used the following code its working pretty nicely in FF. Everything is ok in IE too except the ‘background’
It’s not appearing in IE.

#header{
width:1000px;
min-height:230px;
margin:0 auto 0 auto;
padding:0;
position:relative;
background:url(../images/header_bg1.png)top left no-repeat;
}

If I try “background:#ff0000;”. Its working means colors are appearing but not the image. Please help

to post a comment
CSS

9 Comments(s)

Copy linkTweet thisAlerts:
@FangMar 09.2010 — Add a space after the image url and before 'top'
Copy linkTweet thisAlerts:
@jaypicsauthorMar 10.2010 — Thank you very much it worked. Can you help me with the css of a combo box i.e., <select></select>. The CSS is possible but the problem is with the drop down I am unable to CSS it. Pls help
Copy linkTweet thisAlerts:
@FangMar 10.2010 — The CSS is possible but the problem is with the drop down I am unable to CSS it. Pls help[/QUOTE]
To do what exactly?
Copy linkTweet thisAlerts:
@jaypicsauthorMar 10.2010 — I want to make a country selector using a <select> element in the page. To maintain the same look and feel I want that <select> element to CSS.


"Its like without any borders just the text and the arrow upside down but in a different color."
Copy linkTweet thisAlerts:
@jaypicsauthorMar 12.2010 — I tried it with the java script and its working too but only in FF. The concept is like the <select> element it converted into <ul> . But its not working in IE.
Copy linkTweet thisAlerts:
@FangMar 12.2010 — We need to see what you have done if you require further help.
Copy linkTweet thisAlerts:
@jaypicsauthorMar 13.2010 — //Follwing is the code for <select> element in the HTML page.

<form>

<select id="myselectbox" name="myselectbox">

<option value="1">India</option>

<option value="2">Pakistan</option>

<option value="3">Bangladesh</option>

<option value="4">SriLanka</option>

<option value="5">Baluchistan</option>

</select>

</form>

//following is the code where the <select> element is converted into <ul> and CSS it as //it is a normal <ul>. This one is nicely working in FF but not in IE.

function selectReplacement(obj) {

// append a class to the select

obj.className += ' replaced';

//create list style for styling

var ul = document.createElement('ul');

ul.className = 'selectReplacement';

if (window.attachEvent) {

ul.onmouseover = function() {

ul.className += ' selHover';

}

ul.onmouseout = function() {

ul.className =

ul.className.replace(new RegExp(" selHoverb"), '');

}

}

// collect our object&#8217;s options

var opts = obj.options;

// check for the selected option (default to the first option)

for (var i=0; i<opts.length; i++) {

var selectedOpt;

if (opts[i].selected) {

selectedOpt = i;

break; // we found the selected option, leave the loop

} else {

selectedOpt = 0;

}

}



// iterate through them, creating <li>s

for (var i=0; i<opts.length; i++) {

var li = document.createElement('li');

var txt = document.createTextNode(opts[i].text);

li.appendChild(txt);

li.selIndex = opts[i].index;

li.selectID = obj.id;

li.onclick = function() {

setVal(this.selectID, this.selIndex);

selectMe(this);

}



if (i == selectedOpt) {
li.className = 'selected';
}
if (window.attachEvent) {
li.onmouseover = function() {
this.className += ' selHover';
}
li.onmouseout = function() {
this.className =
this.className.replace(new RegExp(" selHover\b"), '');
}
}


ul.appendChild(li);

}

// add the ul to the form

obj.parentNode.appendChild(ul);

}

// ***********************************************************************************

function setForm() {

var s = document.getElementsByTagName('select');

for (var i=0; i<s.length; i++) {

selectReplacement(s[i]);

}

}

window.onload = function() {

setForm();

}

//
*
**
********************************************************************************

function selectMe(obj) {

// get the <li>&#8217;s siblings

var lis = obj.parentNode.getElementsByTagName('li');

// loop through

for (var i=0; i<lis.length; i++) {

// not the selected <li>, remove selected class

if (lis[i] != obj) {

lis[i].className='';

} else { // our selected <li>, add selected class

lis[i].className='selected';

}

}

}

//
*
**
********************************************************************************

function setVal(objID, selIndex) {

var obj = document.getElementById(objID);

obj.selectedIndex = selIndex;

}





//Please try this code and give some suggestion
Copy linkTweet thisAlerts:
@FangMar 13.2010 — Produces a ul list in IE
×

Success!

Help @jaypics 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.17,
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,
)...