HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<div class="content">
<div id="section"> <div id="toolbar">
<div id="drag"></div>
<img src="https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/dragon_button2.png" id="changeD">
<img src="https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/dragon_button3.png" id="changeA">
<img src="https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/dragon_button4.png" id="changeF">
</div>
<div id="dragonImg">
</div>
<img id="dragon" src="https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/dragon1.png">
<h1>Realest Real Estate :-)</h1>
<h3></h3>
<p><br>
Any white man can sell you a home - it's just a bunch of papers you need to sign!<br>
What we at "Realest Real Estate :-)"™ promise is a unique, revolutionary home-buying experience. No more boring "open houses" or "meetings" about "your needs, expectations and budget".<br><br>
Here at "Realest Real Estate :-)"™ we promise a once in a life time home purchasing adventure! Three masked men will whisk you away from your current residence under the cover of the darkest of nights, and drive you by carriage to the proscpective house. You will be bound, gagged and covered in masking-tape and wood shavings. The music will be loud and very European. After you have experienced every lovely room in the house, three cats will be released from crates. You must choose the best cat, and it is yours to keep. If you wish to buy the house you are currently in, <b>CONGRATULATIONS ON YOUR NEW HOUSE!!!</b> If, however, you wish to keep looking - you must simply figure out the next address.
</p><br><br>
<iframe id="player" frameborder="0" allowfullscreen="1" title="YouTube video player" width="854" height="480"
src="https://www.youtube.com/embed/DCu1G2rxj5c?enablejsapi=1&origin=http%3A%2F%2Fmgapcdev.com"></iframe><br>
<button type="button" id="clearDragon">Clear Dragon-Drops</button>
<div style="clear:both"></div>
</div>
</div>
.content #drag{
cursor: pointer;
}
#dragon{
display: none;
opacity: 0.7;
position: absolute;
height: 300px;
border: 3px solid rgba(0,0,0,0);
}
.dragon{
position: absolute;
height: 300px;
border: 3px solid rgba(0,0,0,0);
}
.border_dragon{
border: 3px dashed black;
}
.flip-horizontal {
-moz-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
-o-transform: scaleX(-1);
transform: scaleX(-1);
-ms-filter: fliph; /*IE*/
filter: fliph; /*IE*/
}
#toolbar{
position: absolute;
top: 75px;
left:0;
height: 644px;
width: 189px;
background-image: url(https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/toolbar.png);
padding-top: 125px;
background-repeat: no-repeat;
z-index: 95;
}
#toolbar img, #toolbar div{
position: relative;
margin: 10px;
margin-left: 30px;
cursor: pointer;
}
#toolbar #drag{
background-image: url(https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/dragon_button5.png);
width: 102px;
height: 100px;
}
var varX;
var varY;
var varSrc;
var highlight_element;
var dragonNum = 0;
var defaultSrc = 'https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/dragon1.png';
var baseURL = 'https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/';
var extension = '.png';
var dragon1 = baseURL + "dragon1" + extension;
var dragon2 = baseURL + "dragon2" + extension;
var dragon3 = baseURL + "dragon3" + extension;
var dragon4 = baseURL + "dragon4" + extension;
$(document).ready(function(){
$('.dragon').removeClass('border_dragon');
dragonNum = $('#totalDragon').attr('totalDragon');
$("#drag").draggable({helper:"clone",
start: function() {
// Nothing
},
drag: function(event) {
event = event || window.event;
varX = event.clientX -100;
varY = event.clientY -100;
$('#dragon').show().css('top',event.clientY-100).css('left',event.clientX-100);
},
stop: function() {
$('#dragon').hide();
$('#dragonImg').append('<img src="'+dragon1+'"" style="top:'+varY+'px; left:'+varX+'px;" class="dragon" dragonNum="'+dragonNum+'">');
/*
$.post(
'/php/article/dragonDrop/setDragonCookie.php',
{dragonSrc: defaultSrc, dragonTop: varY+'px', dragonLeft:varX+'px', dragonClass:'dragon', num: dragonNum}
);*/
dragonNum++;
}
});
/**
* Refreshes which 'dragon' to highlight.
*/
$(document).on('click', '.dragon',function(){
$('.dragon').removeClass('border_dragon');
$(this).addClass('border_dragon');
highlight_element = $(this);
varSrc = highlight_element.attr('src');
});
/**
* Changes between the two 'dragons'.
*/
$('#changeD').click(function(){
varSrc = highlight_element.attr('src');
switch(varSrc){
case dragon1:
changeSrc(dragon2);
break;
case dragon2:
changeSrc(dragon1);
break;
case dragon3:
changeSrc(dragon4);
break;
case dragon4:
changeSrc(dragon3);
break;
}
getAttr();
setCookie();
});
/**
* Changes whether to show an ad on 'dragon'.
*/
$('#changeA').click(function(){
varSrc = highlight_element.attr('src');
switch(varSrc){
case dragon1:
changeSrc(dragon3);
break;
case dragon2:
changeSrc(dragon4);
break;
case dragon3:
changeSrc(dragon1);
break;
case dragon4:
changeSrc(dragon2);
break;
}
getAttr();
setCookie();
});
/**
* Creates a copy of selected dragon and flips it horizontally.
*/
$('#changeF').click(function(){
varSrc = highlight_element.attr('src');
topV = highlight_element.css('top');
topV = topV.replace(/\D/g,'');
leftV = highlight_element.css('left');
if(varSrc == dragon1 || varSrc == dragon3){
leftV = parseInt(leftV.replace(/\D/g,'')) - 341;
}else if(varSrc == dragon2 || varSrc == dragon4){
leftV = parseInt(leftV.replace(/\D/g,'')) - 248;
}
$('#dragonImg').append('<img src="'+varSrc+'" style="top:'+topV+'px; left:'+leftV+'px;" class="dragon flip-horizontal" dragonNum="'+dragonNum+'">');
/*$.post(
'/php/article/dragonDrop/setDragonCookie.php',
{dragonSrc: varSrc, dragonTop: topV+'px', dragonLeft:leftV+'px', dragonClass:'dragon flip-horizontal', num: dragonNum}
);*/
dragonNum++;
getAttr();
setCookie();
});
/**
* Removes highlight if click event doesn't hit toolbar or a dragon.
*/
$(document).click(function(e) {
if ( $(e.target).closest('.dragon').length === 0 ) {
if ( $(e.target).closest('#toolbar').length === 0 ) {
$('.dragon').removeClass('border_dragon');
highlight_element = null;
}
}
});
/**
* Clears all cookies that specify dragons and refreshes page.
*/
$('#clearDragon').click(function(){
/*$.post('/php/article/dragonDrop/clearDragonCookie.php', function(){
window.location.href = "/project/dragon-drop-demo";
});*/
});
});
var topPX;
var leftPX;
var varClass;
var varDragon;
/**
* Changes the source of highlighted element
*/
function changeSrc(source){
highlight_element.attr('src', source);
}
/**
* Refreshes the attributes on the highlighted element.
*/
function getAttr(){
varSrc = highlight_element.attr('src');
topPX = highlight_element.css('top');
leftPX = highlight_element.css('left');
varClass = highlight_element.attr('class');
varDragon = highlight_element.attr('dragonNum');
}
/**
* Updates the highlighted dragon's cookie.
*/
function setCookie(){
/*$.post(
'/php/article/dragonDrop/setDragonCookie.php',
{dragonSrc: varSrc, dragonTop: topPX, dragonLeft: leftPX, dragonClass: varClass, num: varDragon}
);*/
}
Also see: Tab Triggers