В настоящее время я использую Javascript для отображения животных и их информации на странице HMTL.
В настоящее время отображается изображение кролика и информация, подобная этой:
BUNNY IMAGE
Возрастной диапазон: 3 месяца - 2 года
Макс. Принять: 1-2
Связанные пары: Да
Необходимые дома: 5
Мне нужно сделать параметр Возрастной диапазон, Максимальное принятие и т. Д. Параметром вместо того, чтобы просто сделать текст жирным шрифтом и написать его.вот мой JS:
var bunny = {
animalName: 'Bunny',
bondedPairs: '<b>Bonded Pairs: </b> Yes',
maxAdopt: "<b>Max adopt: </b> 1-2",
ageRange: "<b>Age Range: </b> 3 months - 2 Years",
needingHomes: '<b>Needing homes: </b> 5',
avatarSrc: '../images/bunny.jpg',
note: 'note: We have lots of adorable fluffy loafs looking for their forever homes.',
createProfile: function() {
//creates a div to store their staff info
var profile = document.createElement("div");
//sets the class
profile.className = "animalProfile";
//creates a new image for the profile pic
var avatar = document.createElement("img");
//sets the source and name based on our object info
avatar.src = this.avatarSrc;
avatar.alt = this.animalName;
//appends the image to the profile div
profile.appendChild(avatar);
//sets up the text
var profileTxt = document.createElement("p");
profileTxt.innerHTML = "<b>" + this.animalName + "</b><br />" +
"</b><br />" + this.ageRange + "</b><br />" + this.maxAdopt +
" </b><br / > " + this.bondedPairs +
"</b><br />" + this.needingHomes;
//adds the text to the profile div
profile.appendChild(profileTxt);
//returns the completed profile
return profile;
}
}
document.getElementById("animal_list").appendChild(bunny.createProfile());
var bunny = {
animalName: 'Bunny',
bondedPairs: '<b>Bonded Pairs: </b> Yes',
maxAdopt: "<b>Max adopt: </b> 1-2",
ageRange: "<b>Age Range: </b> 3 months - 2 Years",
needingHomes: '<b>Needing homes: </b> 5',
avatarSrc: '../images/bunny.jpg',
note: 'note: We have lots of adorable fluffy loafs looking for their forever homes.',
createProfile: function() {
//creates a div to store their staff info
var profile = document.createElement("div");
//sets the class
profile.className = "animalProfile";
//creates a new image for the profile pic
var avatar = document.createElement("img");
//sets the source and name based on our object info
avatar.src = this.avatarSrc;
avatar.alt = this.animalName;
//appends the image to the profile div
profile.appendChild(avatar);
//sets up the text
var profileTxt = document.createElement("p");
profileTxt.innerHTML = "<b>" + this.animalName + "</b><br />" +
"</b><br />" + this.ageRange + "</b><br />" + this.maxAdopt +
" </b><br / > " + this.bondedPairs +
"</b><br />" + this.needingHomes;
//adds the text to the profile div
profile.appendChild(profileTxt);
//returns the completed profile
return profile;
}
}
document.getElementById("animal_list").appendChild(bunny.createProfile());
body {
background-color: lightblue;
}
#container {
margin: 0 auto;
width: 80%;
}
header {
width: 100%;
text-align: center;
}
section {
width: 100%;
text-align: center;
}
h1 {
color: navy;
font-family: 'Sofia', cursive;
font-size: 2.5em;
padding-top: 20px;
}
p {
font-family: 'Quicksand', sans-serif;
font-size: 16pt;
text-align: center;
}
.animalProfile {
display: inline-block;
background-color: rgba(255, 255, 255, 0.5);
width: 320px;
height: 600px;
border-radius: 5px;
padding: 10px;
margin: 10px;
vertical-align: top;
}
.animalProfile img {
max-width: 300px;
border-radius: 5px;
border: 2px solid #4d4d4d;
}
.animalProfile p {
font-size: 12pt;
text-align: left;
margin: 10px;
}
<!DOCTYPE html>
<html>
<head>
<title>Animal Adoption</title>
<meta charset="utf-8" />
<link href="https://fonts.googleapis.com/css?family=Sofia" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css?family=Quicksand" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="../css/adopt_styles.css" />
</head>
<body>
<div id="container">
<header>
<h1 id="heading" class="blueTxt">Our Animals to Adopt</h1>
</header>
<p>All our animals are available to adopt to proven loving and caring homes with responsible owners.</p>
<section>
<div id="animal_list">
</div>
</section>
</div>
<script src="../js/animal_script.js"></script>
</body>
</html>