JSFiddle - React, Tailwind, and code Playground
by Daniel Hall
HTML
<div id="inputWords">
<ul>
<li>
<input type="text" id="adj1">
<br>name
</li>
<!-- put other input fields here -->
</ul>
</div>
<div id="story">
</div>
<button id="replaceButton">want your babys come and get!</button>
<div id="haed"></div>
<div class="eye" id="righteye"></div>
<div class="eye" id="lefteye"></div>
<div id="mouth"></div>
<div id="bl"></div>
<div id="hair"></div>
<div id="baby"></div>
CSS
body {
font-family: "Comic Sans MS";
background-color: black;
}
#inputWords {
float:left;
width: 45%;
}
ul {
list-style-type: none;
padding: 0px;
margin: 0px;
}
li {
line-height: 2em;
text-transform: uppercase;
margin-top: 8px;
}
input[type=text] {
border-width: 0 0 1px 0;
border-color: #333;
}
#buttonDiv {
text-align: center;
}
#replaceButton {
margin-top: 30px;
width: 200px;
}
#story {
margin-top: 12px;
width: 45%;
border: 1px dashed blue;
padding: 8px;
float: left;
}
.replacement {
text-decoration: underline;
text-transform: uppercase;
}
#haed {
position: absolute;
left: 30%;
top: 30%;
width: 30%;
height: 30%;
background-color: pink;
border-radius: 50px;
}
.eye {
background-color: black;
width: 5%;
height: 5%;
border-radius: 50%;
}
#righteye {
position: absolute;
top: 35%;
left: 35%;
}
#lefteye {
position: absolute;
top: 35%;
left: 50%;
}
#mouth {
position: absolute;
left: 34%;
top: 50%;
width: 20%;
height: 3%;
background-color: black;
}
#bl {
position: absolute;
left: 25%;
top: 55%;
width: 40%;
height: 45%;
background-color: blue;
}
#hair {
position: absolute;
left: 30%;
top: 30%;
width: 30%;
height: 5%;
background-color: white;
}
#baby {
position: absolute;
left: 40%;
top: 80%;
width: 10%;
height: 10%;
border-radius: 50px;
background-color: blue;
}
JavaScript
var replaceButton = document
.getElementById("replaceButton");
replaceButton.addEventListener("click",replaceIt);
function replaceIt() {
document.getElementById("haed").style.backgroundColor = "green";
// Change the text color.
document.getElementById("story").style.color = "red";
document.getElementById("baby").style.backgroundColor = "pink"
var storyDiv = document.getElementById("story");
var adj1 = "<span class='replacement'>"+ document
.getElementById("adj1").value + "</span>";
/* Insert more varible definitions here */
var theStory = "<h1>Your wife had</h1>";
theStory += "899 girls and 955 boys that coats $999.365 and I named them " + adj1 + "";
/* Put the the story here, using the +=
operator */
storyDiv.innerHTML = theStory;
}