cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div style="width:900px; text-align:left; margin: 0px auto 0px auto; padding:20px;">

<span class="navpart">Image Maps and Random Elements</span>

<br />

<div class="left">

<div style="display:inline-block; margin:0px 20px 0px 0px; text-align:left; vertical-align:middle;">
<span class="bolet">Alternative Image Map:</span>
<br />
Smooths the map: *:focus { outline:none; } 
<br />
Determines layering if images overlap (bigger on top): z-index:7; z-index:5; etc.
<br />
Positioning precision: float:left; border-style:none; padding:0px; margin:0px;
<br />
Relative coordinates: position:relative; left:50px; top:50px;
</div>



<br /><br />

<div style="width:87px; height:60px; background-image:url(design/map01.gif); margin:0px 20px 10px 0px; padding:0px; border-style:none; float:left;">
<a class="maplink" href="#"><div id="leftc" class="imap"></div></a>
<a class="maplink" href="#"><div id="midc" class="imap"></div></a>
<a class="maplink" href="#"><div id="rightc" class="imap"></div></a>
</div>

Candle image sizes (width x height):
&nbsp;
Full picture: 87 x 60
&nbsp;
Candles: 10 x 25
<br />

Candle relative positions:
&nbsp;
Left: left: 16 top: 1
&nbsp;
Middle: left: 37 top: 12
&nbsp;
Right: left: 62 top: 5
<br />

Default candle positions:
&nbsp;
Left: left: 0 top: 0
&nbsp;
Middle: left: 10 top: 0
&nbsp;
Right: left: 20 (10+10) top: 0
<br />

Relative position calculations:
&nbsp;
Middle: left: 27 (37-10) top: 12 (12-0)
&nbsp;
Right: left: 42 (62-20) top: 5 (5-0)

<br /><br />

&lt;div style="width:87px; height:60px; background-image:url(map01.gif); margin:0px; padding:0px; border-style:none;"&gt;
<br />
&lt;a class="maplink" href="#"&gt;&lt;div id="leftc" class="imap"&gt;&lt;/div&gt;&lt;/a&gt;
<br />
&lt;a class="maplink" href="#"&gt;&lt;div id="midc" class="imap"&gt;&lt;/div&gt;&lt;/a&gt;
<br />
&lt;a class="maplink" href="#"&gt;&lt;div id="rightc" class="imap"&gt;&lt;/div&gt;&lt;/a&gt;
&nbsp;
&lt;/div&gt;

<br /><br />

div.imap { padding:0px; border-style:none; margin:0px; float:left; position:relative; }
<br />
div#leftc { background-image:url(map03.gif); width:10px; height:25px; left:16px; top:1px; }
<br />
div#leftc:hover { background-image:url(map04.gif); }
<br />
div#midc { background-image:url(map05.gif); width:10px; height:25px; left:27px; top:12px; }
<br />
div#midc:hover { background-image:url(map06.gif); }
<br />
div#rightc { background-image:url(map07.gif); width:10px; height:25px; left:42px; top:5px; }
<br />
div#rightc:hover { background-image:url(map08.gif); }
<br />
a.maplink { padding:0px; margin:0px; background-image:none; }

<br /><br />

<?php $part1 = "none"; $part2 = "none"; $part3 = "none";

$totaldiv = mt_rand(1,3); 

switch ($totaldiv) {

case "1": $part1 = "block"; break;
case "2": $part2 = "block"; break;
case "3": $part3 = "block"; break; } ?>

<span class="bolet">PHP Random Element:</span> 
 
This code displays one random div out of a group every time the page loads. 

There can't be any empty divs in the middle but there can be empty or inactive divs at the start or end. 

Only divs between the random numbers (including those numbers) will be selected. 

<br /><br />

&lt;?php $part1 = "none"; $part2 = "none"; $part3 = "none";
&nbsp;
$totaldiv = mt_rand(1,3); 
&nbsp;
switch ($totaldiv) {
<br />
case "1": $part1 = "block"; break;
&nbsp;
case "2": $part2 = "block"; break;
&nbsp;
case "3": $part3 = "block"; break;
 } ?&gt;

<br /><br />
&lt;div class="randiv" style="display:&lt;?php echo $part1; ?&gt;;"&gt;
&lt;img src="design/pixel/Yummy_Sweets.gif" alt="" /&gt;
&lt;/div&gt;
<br />
&lt;div class="randiv" style="display:&lt;?php echo $part2; ?&gt;;"&gt;
&lt;img src="design/pixel/More_Sweets.gif" alt="" /&gt;
&lt;/div&gt;
<br />
&lt;div class="randiv" style="display:&lt;?php echo $part3; ?&gt;;"&gt;
&lt;img src="design/pixel/Chocolate_Sweets.gif" alt="" /&gt;
&lt;/div&gt;

<br /><br />

<span class="bolet">JS Random Element:</span> 

This code can only have inactive elemets at the end.

You can use the code in the page or in an iframe for buttons rotations.

<br /><br />

&lt;iframe style="width:50px; height:50px; border:0px none; padding:0px; margin:0px auto 0px auto; overflow:hidden;" id="button" name="button" src="design/code14butro.html"&gt;&lt;/iframe&gt;

<br /><br />

&lt;!DOCTYPE html&gt;   &lt;head&gt;   &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&nbsp;
&lt;title&gt; button &lt;/title&gt;
<br />
&lt;style type="text/css" media="all"&gt;
&nbsp;
body { overflow:hidden; }
&nbsp;
* { margin:0px; padding:0px; }
&nbsp;
*:focus { outline: 0px none; }
&nbsp;
&lt;/style&gt;
<br /><br />
&lt;script&gt;
&nbsp;
function ranlink() { var thesites = 3;
&nbsp;
thesites = Math.floor( (thesites) * (Math.random()) ) + 1;
<br />
if (thesites==1) { document.getElementById("linksite").src = "Yummy_Sweets.gif"; 
document.getElementById("findsite").href = "#"; }
<br />
if (thesites==2) { document.getElementById("linksite").src = "More_Sweets.gif"; 
document.getElementById("findsite").href = "#"; }
<br />
if (thesites==3) { document.getElementById("linksite").src = "Chocolate_Sweets.gif"; 
document.getElementById("findsite").href = "#"; }
&nbsp; }
&lt;/script&gt;
<br /><br />
&lt;/head&gt; &lt;body onload="ranlink();"&gt;
<br />
&lt;a id="findsite" target="_blank" href="#"&gt;&lt;img src="More_Sweets.gif" id="linksite" alt="" style="float:left;" /&gt;&lt;/a&gt;
<br />
&lt;/body&gt; &lt;/html&gt; 

</div>
<br />
<a href="http://azurelight.net">AzureLight.net</a> | 
<a href="http://mikaristar.deviantart.com">MikariStar.DeviantArt.com</a> | 
<a href="http://artrift.com/Mikari/">ArtRift.com/Mikari/</a> | 
<a href="http://miliazure.wordpress.com">MiliAzure.WordPress.com</a>
</div>
            
          
!
            
              body { padding:0px; margin:0px; font-family:Arial; font-size:14px; line-height:20px; 
color:#393939; background-color:#c2f0ff; text-align:center; }

::-webkit-scrollbar { width: 10px; height:10px; }
::-webkit-scrollbar-track { background-color:#c2f0ff; }
::-webkit-scrollbar-thumb { border-radius: 20px; background-color:#ff9adc; border: 0px none; }

.showbor { border:0px none; border:3px dotted #ff9adc; padding:0px; } 

a { color:#ff71ce; text-decoration:none; }

div.imap { padding:0px; border-style:none; margin:0px; float:left; position:relative; }

div#leftc { background-image:url(design/map03.gif); width:10px; height:25px; left:16px; top:1px; }

div#leftc:hover { background-image:url(design/map04.gif); }

div#midc { background-image:url(design/map05.gif); width:10px; height:25px; left:27px; top:12px; }

div#midc:hover { background-image:url(design/map06.gif); }

div#rightc { background-image:url(design/map07.gif); width:10px; height:25px; left:42px; top:5px; }

div#rightc:hover { background-image:url(design/map08.gif); }

a.maplink { padding:0px; margin:0px; background-image:none; }

div.randiv { width:50px; height:50px; float:left; margin:0px 15px 15px 0px; }
            
          
!
999px
Loading ..................

Console