Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

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.

+ add another resource

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>
<head>
  <title>MAGIC 8 BALL</title>

  <link href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,700|Montserrat:400,700" rel="stylesheet" type="text/css">

  <link rel="stylesheet" type="text/css" href="style.css">
</head>

  <body>
  <div class="page">

    <header>
      <h1>MAGIC <span>8</span> BALL</h1>
    </header>

    <div class="ball">

      <p id="answer" class="answer" align="center" >
        THIS IS WHERE THE ANSWER GOES
      </p>

       <img id="8ball" alt="Magic 8 Ball Default Image" src="https://s3.amazonaws.com/media.skillcrush.com/skillcrush/wp-content/uploads/2016/09/magic8ballQuestion.png">

    </div>

    <br><br>

    <div class="button">
      <button id="questionButton">ASK ME ANYTHING</button>
    </div>

    <footer>
      <p>&copy; 2020 <a href="https://adrianne.dev" target="_blank"> Adrianne P.</a></p>
    </footer>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
  <script type="text/javascript" src="script.js"></script>

  </div>
  </body>

</html>

              
            
!

CSS

              
                body {
  font-family: "Montserrat", sans-serif;
  color: #454545;
  margin: 0px;
  padding: 0px;
  background-color: #f8f8f8;
  background-image: url('bkgd2.png');
}
.page {
  width: 80%;
  max-width: 960px;
  margin: 0 auto;
}
.ball, .button {
  margin: 0 auto;
  position:relative; 
  width:80%;
}
.answer {
  position:absolute;
  width:14%;
  top:50%;
  left:50%;
  margin-top:-60px;
  margin-left:-65px;
  font: 16px 'Open Sans', Helvetica, Arial, sans-serif;
  color: #222;
  text-transform: uppercase;
}

#questionButton {
  font: 26px 'Montserrat', Helvetica, Arial, sans-serif;
  border-radius: 5px;
  border: none;
  color: #f8f8f8;
  background-color: #f16059;
  padding: 10px 75px;
  display: block;
  margin: 0 auto;
}

header {
  padding-top: 0.25em;
  text-align: center;
}
header span {
  font-size: 60px;
  color: #f16059;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Montserrat", sans-serif;
}

footer p {
  font-family: "Montserrat", sans-serif;
  text-align: center;
  text-transform: uppercase;
  font-size: 12px;
}

              
            
!

JS

              
                $(document).ready(function(){
  $("#answer").hide();
var magic8Ball = {};
magic8Ball.answersList = ["It is certain", "It is decidedly so", "Without a doubt", "Yes – definitely", "You may rely on it", "As I see it, yes", "Most likely", "Outlook good", "Yes", "Signs point to yes", "Reply hazy, try again", "Ask again later", "Better not tell you now", "Cannot predict now", "Concentrate and ask again", "Don't count on it", "My reply is no", "My sources say no", "Outlook not so good", "Very doubtful"]; 

magic8Ball.askQuestion = function(ask) {
	var randomNum = Math.random();
	var randomNumAnswers = randomNum * this.answersList.length;
	
	var randomIndex = Math.floor(randomNumAnswers);
	
	var answer = this.answersList[randomIndex];
	$("#8ball").attr("src", "https://s3.amazonaws.com/media.skillcrush.com/skillcrush/wp-content/uploads/2016/09/answerside.png");
	$("#answer").fadeIn(4000);
	$("#answer").text( answer );
	
	console.log(ask);
	console.log(answer);
};

/* magic8Ball.askQuestion("Will I meet MADKID and JO1 anytime soon?"); */
  
  /* this should make the button clickable and a prompt window will appear */
  $("#answer").hide();
	$("#8ball").attr("src", "https://s3.amazonaws.com/media.skillcrush.com/skillcrush/wp-content/uploads/2016/09/8side.png");
  var onClick = function() {
    $("#8ball").effect( "shake" );
 	setTimeout(
		function() {
			var question = prompt("ASK A YES/NO QUESTION!");
    magic8Ball.askQuestion(question);
		}, 500);
  };
  $("#questionButton").click( onClick );
 
});


              
            
!
999px

Console