Skip to content

Commit 467f007

Browse files
committed
updated ex-about me
1 parent 11def15 commit 467f007

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

Week1/js-exercises/ex2-aboutMe.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<body>
1616
<h1>About Me</h1>
1717

18-
<ul>
18+
<ul id="ulElement">
1919
<li>Nickname: <span id="nickname"></span></li>
2020
<li>Favorite food: <span id="fav-food"></span></li>
2121
<li>Hometown: <span id="hometown"></span></li>

Week1/js-exercises/ex2-aboutMe.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,38 @@
99
5. See HTML
1010
6. Create a new img element and set its src attribute to a picture of you.Append that element to the page.
1111
*/
12+
1213
'use strict';
14+
1315
// add a font family to the body
1416
document.body.style.fontFamily = 'arial, sans-serif';
1517

1618
// select the spans by their ID's and add text to them
19+
const ulElement = document.getElementById('ulElement');
20+
ulElement.style.background = 'red';
21+
ulElement.style.borderRadius = '5px';
22+
ulElement.style.width = 'calc(100% - 400px)';
23+
ulElement.style.margin = '0 auto';
1724
const nickName = document.getElementById('nickname');
1825
nickName.textContent = 'Don';
1926
const favFood = document.getElementById('fav-food');
2027
favFood.textContent = 'Fish';
2128
const homeTown = document.getElementById('hometown');
2229
homeTown.textContent = 'Asmara, Eritrea';
23-
const liElement = document.querySelectorAll('li');
30+
const liElements = document.querySelectorAll('li');
31+
// liElements.style.listStyleType = 'none';
2432

25-
//loop through the li's and add them a class name
26-
for (let i = 0; i < liElement.length; i++) {
27-
liElement[i].className = 'list-item';
33+
// loop through the li's and add them a class name
34+
for (let i = 0; i < liElements.length; i++) {
35+
liElements[i].className = 'list-item';
36+
liElements[i].style.listStyleType = 'none';
37+
liElements[i].style.fontSize = '1.5rem';
38+
liElements[i].style.padding = '0.8rem';
2839
}
2940
const myPhoto = document.createElement('img');
30-
myPhoto.src = 'photo.jpg'; //add photo source
31-
document.body.appendChild(myPhoto); //append photo to the page
41+
myPhoto.src = 'photo.jpg'; // add photo source
42+
myPhoto.style.display = 'block';
43+
myPhoto.style.borderRadius = '50%';
44+
myPhoto.style.width = '18.75rem';
45+
myPhoto.style.margin = '0 auto';
46+
document.body.appendChild(myPhoto); // append photo to the page

0 commit comments

Comments
 (0)