answersLogoWhite

0

It's not clear what the questioner means by "load first".

One common way to preload images using CSS, so they will be instantly visible when needed, is to assign them to an element's background, but position them off-screen. For example:

#preloader { background: url(img/image.jpg) no-repeat -9999px -9999px); }

If you later refer to the exact path and file elsewhere, the image will have already cached it because of this.

#preloader is how you would refer to an element like a div, if you assigned it "preloader" as an ID. In CSS, the # symbol is a selector meaning "ID".

But if you mean that you want the background to become visible before the content of the div, this would be more complicated, and probably require JavaScript. You could place another DIV inside the one with the background, but set that div to display:none. Assign an event in javascript to the loading of the background, which will change the inner div to display: block when it's triggered.

Something like:

<head>

<script>

var imagename = new Image();

imagename.onload = function() {

document.getElementById("contentdiv").style.display = "block";

} </script>

<style>

#maindiv {

background: url(img/image.jpg) no-repeat 0 0;

}

#innerdiv {

display: none;

}

</style>

</head>

<body>

<div id="maindiv">

<div id="innerdiv">

This is some stuff that will be hidden until the background image loads

</div>

</div>

</body>

The one downside with this relatively simple answer is that I don't know whether the onload event is triggered if the image is already cached (because the user has been to the site before), so that it loads instantly.

One simple way to ensure that the content will become visible in that case would be to also add a timeout to make it visible after a set time, like:

setTimeout(function() {

document.getElementById("contentdiv").style.display = "block";

}, 3000);

So that if the load event hasn't triggered after three seconds, the content loads anyway. Change the 3000 milliseconds to whatever time you think is ideal.

User Avatar

Wiki User

9y ago

What else can I help you with?

Continue Learning about Engineering

Can you use different divs in the background 'body' div without disturbing the overall flow of the 'container' div?

Yes, the easiest way to do this is to change the z-index of the div so it is generated on a different layer. An example you could do is below: &lt;div style='position:absolute;z-index:-1;'&gt; This will be behind the main div &lt;/div&gt; &lt;div&gt; This is the main div &lt;/div&gt;


How do you set background image in panel?

Yo can set the background image by setting the style element. To put it in a panel, wrap it inside a DIV tag.


How do you place images on a website below each other using CSS?

Don't really need to use CSS, but you can set each image as a background of a div container, or use the image tag inside block level tags like div or paragraph tags. These will ensure that the images go below each other. You can also use unordered list tags, table tags, etc.. The only CSS used then is to make it look the way you want the page to look.


How can you use div under div?

It's not that hard. If this is what you mean: &lt;div&gt; &lt;div&gt; &lt;h1&gt;Some content&lt;/h1&gt; &lt;/div&gt; &lt;/div&gt;


What does the HTML tag do?

A Div tag can be used for formatting a block of text, images, other divs or any other element of a website, even if these elements are included within some other tag. Anything inside a particular div will follow its CSS properties unless you don't specifically change it. Its like a box in which you can add any HTML element, a webpage usually have many divs to create a the layout. The placement and size of the div can be controlled by CSS. The content of the tag &lt;div&gt; always begins with a new line as it is a block based tag. There is also line folding after it.

Related Questions

How generate background for an div?

background-color:#xxx;


Can you use different divs in the background 'body' div without disturbing the overall flow of the 'container' div?

Yes, the easiest way to do this is to change the z-index of the div so it is generated on a different layer. An example you could do is below: &lt;div style='position:absolute;z-index:-1;'&gt; This will be behind the main div &lt;/div&gt; &lt;div&gt; This is the main div &lt;/div&gt;


How do you get a scrool box on MySpace?

&lt;div style="overflow:auto; background-color:transparent; width:337px; height:240px; border:none;"&gt; content here &lt;/div&gt;


How do you make a specific element have different styles than those set for its general element type?

You can counter the styles declared for the general element type. For example, if the earlier CSS declared "background-color: #FF0000;" for all "div" elements, but you want a specific "div" tag to have a different background color, you can add "background-color: #00FF00;" as a declaration to that specific "div" tag. A live example: ---- div { background-color: #FF0000; } This division will be green, not red! ----


Where can i get mweor layouts?

You'll have to know coding. Here's just a really simple one.. &lt;font color=white&gt; &lt;style&gt;div#current,body,div#content,div#bodyi,div#holder,div#layoutuinfo,div#cattery_infobox,div#cattery_descbox,div#titletxt,div.listheader,div#fv invisible,div,tr,td{background:transparent}&lt;/style&gt; &lt;style&gt;body {background:url("http://fc09.deviantart.net/fs16/i/2007/212/1/d/Swirls_and_Seeds_by_melemel.jpg"); background-color: COLOR;} &lt;/style&gt; &lt;center&gt;&lt;span class="tip" tip=" Made by Ivy (#33334) " class="trans"&gt;&lt;img src="http://t3.gstatic.com/images?q=tbn:ANd9GcRgfeBMkB0GwTt3vrmFKGSLIxGM_v11VvjFiQ5nXnK5vpwBRfok" width="12" height="12" class="trans"&gt;&lt;/span&gt;&lt;/center&gt; &lt;center&gt;- - -&lt;/center&gt; &lt;center&gt;&lt;div style="width: 400px; height: 70px; overflow: auto; border: 1px dotted black; background: black;"&gt;&lt;center&gt;&lt;b&gt;Title!&lt;/center&gt;&lt;/b&gt; &lt;center&gt;Text!&lt;/center&gt;&lt;/div&gt; &lt;center&gt;- - -&lt;/center&gt; &lt;div style="width: 200px; height: 15px; overflow: auto; border: 2px solid white; background: black;"&gt; &lt;center&gt;&lt;i&gt;Layout by Ivy (#33334)&lt;/div&gt; If you'd like to learn more about coding, message me... My mweor ID is: 124675


What is the code for a search bar?

Place this code in your page: &lt;style type="text/css"&gt; @import url(http://www.google.com/cse/api/branding.css); &lt;/style&gt; &lt;div class="cse-branding-right" style="background-color:#000000;color:#FFFFFF"&gt; &lt;div class="cse-branding-form"&gt; &lt;form action="http://www.google.com/cse" id="cse-search-box"&gt; &lt;div&gt; &lt;input type="hidden" name="cx" value="partner-pub-0189838191925575:2eywcrgs2pz" /&gt; &lt;input type="hidden" name="ie" value="ISO-8859-1" /&gt; &lt;input type="text" name="q" size="31" /&gt; &lt;input type="submit" name="sa" value="Search" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;div class="cse-branding-logo"&gt; &lt;img src="http://www.google.com/images/poweredby_transparent/poweredby_000000.gif" alt="Google" /&gt; &lt;/div&gt; &lt;div class="cse-branding-text"&gt; Custom Search &lt;/div&gt; &lt;/div&gt; Place this code in your page: &lt;style type="text/css"&gt; @import url(http://www.google.com/cse/api/branding.css); &lt;/style&gt; &lt;div class="cse-branding-right" style="background-color:#000000;color:#FFFFFF"&gt; &lt;div class="cse-branding-form"&gt; &lt;form action="http://www.google.com/cse" id="cse-search-box"&gt; &lt;div&gt; &lt;input type="hidden" name="cx" value="partner-pub-0189838191925575:2eywcrgs2pz" /&gt; &lt;input type="hidden" name="ie" value="ISO-8859-1" /&gt; &lt;input type="text" name="q" size="31" /&gt; &lt;input type="submit" name="sa" value="Search" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;div class="cse-branding-logo"&gt; &lt;img src="http://www.google.com/images/poweredby_transparent/poweredby_000000.gif" alt="Google" /&gt; &lt;/div&gt; &lt;div class="cse-branding-text"&gt; Custom Search &lt;/div&gt; &lt;/div&gt;


How do you put a search bar on your website?

Put this code on your site: &lt;style type="text/css"&gt; @import url(http://www.google.com/cse/api/branding.css); &lt;/style&gt; &lt;div class="cse-branding-right" style="background-color:#000000;color:#FFFFFF"&gt; &lt;div class="cse-branding-form"&gt; &lt;form action="http://www.google.com/cse" id="cse-search-box"&gt; &lt;div&gt; &lt;input type="hidden" name="cx" value="partner-pub-0189838191925575:2eywcrgs2pz" /&gt; &lt;input type="hidden" name="ie" value="ISO-8859-1" /&gt; &lt;input type="text" name="q" size="31" /&gt; &lt;input type="submit" name="sa" value="Search" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;div class="cse-branding-logo"&gt; &lt;img src="http://www.google.com/images/poweredby_transparent/poweredby_000000.gif" alt="Google" /&gt; &lt;/div&gt; &lt;div class="cse-branding-text"&gt; Custom Search &lt;/div&gt; &lt;/div&gt; Put this code on your site: &lt;style type="text/css"&gt; @import url(http://www.google.com/cse/api/branding.css); &lt;/style&gt; &lt;div class="cse-branding-right" style="background-color:#000000;color:#FFFFFF"&gt; &lt;div class="cse-branding-form"&gt; &lt;form action="http://www.google.com/cse" id="cse-search-box"&gt; &lt;div&gt; &lt;input type="hidden" name="cx" value="partner-pub-0189838191925575:2eywcrgs2pz" /&gt; &lt;input type="hidden" name="ie" value="ISO-8859-1" /&gt; &lt;input type="text" name="q" size="31" /&gt; &lt;input type="submit" name="sa" value="Search" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;div class="cse-branding-logo"&gt; &lt;img src="http://www.google.com/images/poweredby_transparent/poweredby_000000.gif" alt="Google" /&gt; &lt;/div&gt; &lt;div class="cse-branding-text"&gt; Custom Search &lt;/div&gt; &lt;/div&gt;


How do you delete your bottom links on myspace?

&lt;style&gt; table tr td div font {display: none;} &lt;/style&gt; &lt;style&gt; table td div {visibility:hidden;} table table td div {visibility:visible;} tr {background:transparent;}&lt;/style&gt; &lt;style&gt; table tr td div div { visibility:hidden; display:none; border:0px!important; background-color:transparent; } &lt;/style&gt;


Names and their information of the latest viruses?

== &lt;table style== "width: 320px; border: 1px solid gray; font: normal 12px sans-serif; background-color: white;"&gt;&lt;tr&gt;&lt;td colspan="2" style="background: white; color: black; padding: 5px;"&gt;&lt;b style="font: bold 20px serif; display: block; margin-bottom: 8px;"&gt;What does your name mean?&lt;/b&gt; &lt;div style="font-size: 16px; margin-bottom: 4px;"&gt;Your Result: &lt;b&gt;LOYALTY&lt;/b&gt;&lt;/div&gt;&lt;div style="width: 200px; backgroundTOOTHBRUSHES HELP OUR TEETH 1px solid black;"&gt;&lt;div style="width: 74%; background: red; font-size: 8px; line-height: 8px;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;p style="margin: 10px; border: none; background: white; color: black;"&gt;You have mostly loyalty in your life. Others trust you because you always tell the truth. Loyalty is one of the best things in life and you got it. Wether living up to a promise or tring to help someone not live it down, your turthful hart is always happy.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="color: black; background: white; padding: 3px;"&gt;JOY&lt;/td&gt;&lt;td style="background: white; padding: 3px;"&gt;&lt;div style="width: 100px; background: white; border: 1px solid black; margin-top: 4px;"&gt;&lt;div style="width: 49%; background: red; font-size: 8px; line-height: 8px;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="color: black; background: white; padding: 3px;"&gt;Independence&lt;/td&gt;&lt;td style="background: white; padding: 3px;"&gt;&lt;div style="width: 100px; background: white; border: 1px solid black; margin-top: 4px;"&gt;&lt;div style="width: 12%; background: red; font-size: 8px; line-height: 8px;"&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td colspan="2" style="text-align: center; padding: 8px;"&gt;&lt;a href="http://www.gotoquiz.com/what_does_your_name_mean_3"&gt;&lt;b&gt;What does your name mean?&lt;/b&gt;&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.gotoquiz.com/"&gt;Quiz Created on GoToQuiz&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; ==


How do you set background image in panel?

Yo can set the background image by setting the style element. To put it in a panel, wrap it inside a DIV tag.


How do you search tinierme background?

You can create you own using this code; &lt;img src="URL FOR BACKGROUND GOES HERE!!!" style="position: fixed; top: 0; left: 0px; width: 100%; height: 100%; z-index: -100;"&gt;&lt;/div&gt; I used PhotoBucket for images. You will have to resize them. Height: 800px Width: 600px


How do you place images on a website below each other using CSS?

Don't really need to use CSS, but you can set each image as a background of a div container, or use the image tag inside block level tags like div or paragraph tags. These will ensure that the images go below each other. You can also use unordered list tags, table tags, etc.. The only CSS used then is to make it look the way you want the page to look.